Skip to content

Commit

Permalink
allow to reopen charging session for conservation charging more than 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Jan 6, 2024
1 parent ad46643 commit e3c2849
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vwsfriend/vwsfriend/agents/charge_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ def __onChargingStateChange(self, element, flags): # noqa: C901
ChargingStatus.ChargingState.CONSERVATION]:
with self.session.begin_nested():
if self.chargingSession is None or self.chargingSession.isClosed():
# In case this was an interrupted charging session (interrupt no longer than 24hours), continue by erasing end time
# In case this was an interrupted charging session (interrupt no longer than or loger if conservation), continue by erasing end time
interruptTimeHours = 24
if element.value in [ChargingStatus.ChargingState.CHARGE_PURPOSE_REACHED_CONSERVATION, ChargingStatus.ChargingState.CONSERVATION]:
interruptTimeHours = 300
if self.chargingSession is not None and not self.chargingSession.wasDisconnected() \
and (self.chargingSession.ended is None or chargeStatus.carCapturedTimestamp.value is None
or self.chargingSession.ended > (chargeStatus.carCapturedTimestamp.value - timedelta(hours=24))):
or self.chargingSession.ended > (chargeStatus.carCapturedTimestamp.value - timedelta(hours=interruptTimeHours))):
self.chargingSession.ended = None
self.chargingSession.endSOC_pct = None
else:
Expand Down

0 comments on commit e3c2849

Please sign in to comment.