Skip to content

Commit

Permalink
fix: Updated total consumption sensors to ignore zero based results r…
Browse files Browse the repository at this point in the history
…eported by home pro (10 minute dev time)
  • Loading branch information
BottlecapDave committed Dec 25, 2024
1 parent 9af97a5 commit 78748d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _handle_coordinator_update(self) -> None:
_LOGGER.debug(f"Calculated total electricity consumption for '{self._mpan}/{self._serial_number}'...")

if consumption_data[-1]["total_consumption"] is not None:
self._state = consumption_data[-1]["total_consumption"]
self._state = consumption_data[-1]["total_consumption"] if consumption_data[-1]["total_consumption"] is not None and consumption_data[-1]["total_consumption"] != 0 else None
self._last_reset = current

self._attributes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def _handle_coordinator_update(self) -> None:

if consumption_data[-1]["total_consumption"] is not None:
if "is_kwh" not in consumption_data[-1] or consumption_data[-1]["is_kwh"] == True:
self._state = convert_kwh_to_m3(consumption_data[-1]["total_consumption"], self._calorific_value) if consumption_data[-1]["total_consumption"] is not None else None
self._state = convert_kwh_to_m3(consumption_data[-1]["total_consumption"], self._calorific_value) if consumption_data[-1]["total_consumption"] is not None and consumption_data[-1]["total_consumption"] != 0 else None
else:
self._state = consumption_data[-1]["total_consumption"]
self._state = consumption_data[-1]["total_consumption"] if consumption_data[-1]["total_consumption"] is not None and consumption_data[-1]["total_consumption"] != 0 else None

self._attributes = {
"mprn": self._mprn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def _handle_coordinator_update(self) -> None:

if consumption_data[-1]["total_consumption"] is not None:
if "is_kwh" not in consumption_data[-1] or consumption_data[-1]["is_kwh"] == True:
self._state = consumption_data[-1]["total_consumption"]
self._state = consumption_data[-1]["total_consumption"] if consumption_data[-1]["total_consumption"] is not None and consumption_data[-1]["total_consumption"] != 0 else None
else:
self._state = convert_m3_to_kwh(consumption_data[-1]["total_consumption"], self._calorific_value) if consumption_data[-1]["total_consumption"] is not None else None
self._state = convert_m3_to_kwh(consumption_data[-1]["total_consumption"], self._calorific_value) if consumption_data[-1]["total_consumption"] is not None and consumption_data[-1]["total_consumption"] != 0 else None

self._attributes = {
"mprn": self._mprn,
Expand Down

0 comments on commit 78748d1

Please sign in to comment.