Skip to content

Commit

Permalink
Merge pull request #318 from zabuldon/dev
Browse files Browse the repository at this point in the history
fix: improve handling on 0 Watts spurious power reads (#317)
  • Loading branch information
alandtse authored May 26, 2022
2 parents 0da6019 + 213a8e2 commit 00af374
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion teslajsonpy/homeassistant/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@ def refresh(self) -> None:
"""
super().refresh()
data = self._controller.get_power_params(self._id)

if data:
# Note: Some systems that pre-date Tesla aquisition of SolarCity will have `grid_status: Unknown`,
# but will have solar power values
# but will have solar power values. At the same time, newer systems will report spurious reads of 0 Watts
# and grid status unknown. If solar power is 0 return null.
if "grid_status" in data and data["grid_status"] == "Unknown" and data["solar_power"] == 0:
_LOGGER.debug("Spurious energy site power read")
return

self.__power = data["solar_power"]
if data["solar_power"] is not None:
self.__generating_status = (
Expand Down

0 comments on commit 00af374

Please sign in to comment.