Skip to content

Commit

Permalink
fix: Fixed issue with current consumption sensor not working properly…
Browse files Browse the repository at this point in the history
… in energy dashboard
  • Loading branch information
BottlecapDave committed Nov 24, 2023
1 parent 2e3900f commit 08af21b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from homeassistant.util.dt import (now)
import logging

from homeassistant.core import HomeAssistant
from homeassistant.util.dt import (now)

from homeassistant.helpers.update_coordinator import (
CoordinatorEntity
Expand Down Expand Up @@ -90,6 +90,7 @@ def native_value(self):
total_consumption,
self._attributes["last_evaluated"] if "last_evaluated" in self._attributes and self._attributes["last_evaluated"] is not None else current_date,
self._previous_total_consumption)

if (self._state is not None):
self._latest_date = current_date
self._attributes["last_evaluated"] = current_date
Expand All @@ -111,5 +112,9 @@ async def async_added_to_hass(self):

if "last_updated_timestamp" in self._attributes:
del self._attributes["last_updated_timestamp"]

# With this included, was causing issues with statistics. Why other sensors are not effected...
if "last_reset" in self._attributes:
del self._attributes["last_reset"]

_LOGGER.debug(f'Restored OctopusEnergyCurrentElectricityConsumption state: {self._state}')
6 changes: 5 additions & 1 deletion custom_components/octopus_energy/gas/current_consumption.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from homeassistant.util.dt import (now)
import logging

from homeassistant.core import HomeAssistant
from homeassistant.util.dt import (now)

from homeassistant.helpers.update_coordinator import (
CoordinatorEntity
Expand Down Expand Up @@ -111,5 +111,9 @@ async def async_added_to_hass(self):

if "last_updated_timestamp" in self._attributes:
del self._attributes["last_updated_timestamp"]

# With this included, was causing issues with statistics. Why other sensors are not effected...
if "last_reset" in self._attributes:
del self._attributes["last_reset"]

_LOGGER.debug(f'Restored OctopusEnergyCurrentGasConsumption state: {self._state}')

0 comments on commit 08af21b

Please sign in to comment.