Skip to content

Commit 3d69ea5

Browse files
committed
fix timers bug
1 parent 77c4f32 commit 3d69ea5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

weconnect/elements/charging_profiles.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,15 @@ def __init__(
244244
def update(self, fromDict):
245245
LOG.debug('Update nextChargingTimer from dict')
246246

247-
if 'id' in fromDict and fromDict['id'] < len(self.parent.profiles):
248-
self.timer = self.parent.profiles[fromDict['id']]
247+
if 'id' in fromDict and fromDict['id'] is not None:
248+
foundTimer = False
249+
for profile in self.parent.profiles.values():
250+
if fromDict['id'] in profile.timers:
251+
self.timer = profile.timers[fromDict['id']]
252+
foundTimer = True
253+
break
254+
if not foundTimer and self.timer is not None:
255+
self.timer = None
249256

250257
self.targetSOCreachable.fromDict(fromDict, 'targetSOCreachable')
251258

0 commit comments

Comments
 (0)