Skip to content

Commit

Permalink
reset session on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Jun 24, 2024
1 parent 8d0c302 commit 350c219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def charger_active(self) -> bool:
) # todo: composition
return all(
[
# self.controller.hub.sensors.chargerobject_switch.value, # todo: possibly remove to allow chargertypes without switch.
self.controller.hub.sensors.carpowersensor.value
> 0, # todo: composition
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,18 @@ async def async_check_broadcasting(
match new_state:
case ChargeControllerStates.Idle:
await self.hub.observer.async_broadcast(ObserverTypes.CarDisconnected)
await self.session.async_reset(
getattr(
self.hub.sensors.locale.data.query_model,
'charged_peak',
0,
)
)
if self.hub.charger_done:
await self.hub.observer.async_broadcast(
ObserverTypes.UpdateChargerDone, False
)

case ChargeControllerStates.Done:
await self.hub.observer.async_broadcast(ObserverTypes.UpdateChargerDone, True)
case ChargeControllerStates.Charging | ChargeControllerStates.Start | ChargeControllerStates.Stop | ChargeControllerStates.Connected:
Expand Down

0 comments on commit 350c219

Please sign in to comment.