Skip to content

Commit

Permalink
attempt at #342
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Jun 11, 2024
1 parent 50231a4 commit 1aaadd2
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def async_update_sensor_internal(self, entity, value) -> bool:
async def async_handle_powersensor(self, value) -> None:
await self.hub.sensors.power.async_update(
carpowersensor_value=self.hub.sensors.carpowersensor.value,
config_sensor_value=value,
config_sensor_value=value if isinstance(value, (float, int)) else None
)
self.hub.power.power_canary.total_power = (
self.hub.sensors.power.total.value
Expand Down Expand Up @@ -138,15 +138,16 @@ async def async_update_sensor_internal(self, entity, value) -> bool:
update_session = False
match entity:
case self.hub.options.powersensor:
await self.hub.sensors.power.async_update(
carpowersensor_value=0, config_sensor_value=value
)
update_session = True
self.hub.power.power_canary.total_power = (
self.hub.sensors.power.total.value
)
self.hub.sensors.power_trend.add_reading(self.hub.sensors.power.total.value, time.time())
self.hub.sensors.power_sensor_moving_average_5.add_reading(self.hub.sensors.power.total.value)
if isinstance(value, (float, int)):
await self.hub.sensors.power.async_update(
carpowersensor_value=0, config_sensor_value=value
)
update_session = True
self.hub.power.power_canary.total_power = (
self.hub.sensors.power.total.value
)
self.hub.sensors.power_trend.add_reading(self.hub.sensors.power.total.value, time.time())
self.hub.sensors.power_sensor_moving_average_5.add_reading(self.hub.sensors.power.total.value)
case self.hub.sensors.totalhourlyenergy.entity:
await self.async_update_total_energy_and_peak(value)
case self.hub.sensors.powersensormovingaverage.entity:
Expand Down

0 comments on commit 1aaadd2

Please sign in to comment.