Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
Correct bug causing energy spikes on energy dashboard
  • Loading branch information
hif2k1 authored Dec 7, 2022
1 parent 830935e commit e76fc18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/battery_sim/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ async def async_added_to_hass(self):
if state:
try:
self._handle._sensors[self._sensor_type] = float(state.state)
self._last_reset = dt_util.as_utc(
dt_util.parse_datetime(state.attributes.get(ATTR_LAST_RESET))
)
self._available = True
await self.async_update_ha_state(True)
except:
_LOGGER.debug("Sensor state not restored properly.")
if self._sensor_type == GRID_IMPORT_SIM:
Expand Down Expand Up @@ -435,4 +440,4 @@ def state(self):
return self.handle._sensors[BATTERY_MODE]

def update(self):
"""Not used"""
"""Not used"""

0 comments on commit e76fc18

Please sign in to comment.