Skip to content

Commit

Permalink
Merge pull request #492 from WillCodeForCats/new-entity-checks
Browse files Browse the repository at this point in the history
Only log energy 'went backwards' once per event
  • Loading branch information
WillCodeForCats authored Jan 5, 2024
2 parents 7ac20d8 + 4f2273c commit e625dc6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions custom_components/solaredge_modbus_multi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ def __init__(self, platform, config_entry, coordinator, phase: str = None):
self._phase = phase
self._last = None
self._value = None
self._log_once = False

if self._phase is None:
self._model_key = "AC_Energy_WH"
Expand Down Expand Up @@ -920,10 +921,13 @@ def available(self) -> bool:
)

if self._value < self._last:
_LOGGER.warning(
"Inverter accumulator went backwards; this is a SolarEdge bug:"
f"total_increasing {self._model_key} {self._value} < {self._last}"
)
if not self._log_once:
_LOGGER.warning(
"Inverter accumulator went backwards; this is a SolarEdge bug: "
f"{self._model_key} {self._value} < {self._last}"
)
self._log_once = True

return False

except KeyError:
Expand All @@ -933,6 +937,7 @@ def available(self) -> bool:
_LOGGER.debug(f"total_increasing {self._model_key} exception: {e}")
return False

self._log_once = False
return super().available

@property
Expand Down

0 comments on commit e625dc6

Please sign in to comment.