Skip to content

Commit 08127b3

Browse files
Robust handling of last reported timezone
1 parent 6537ee3 commit 08127b3

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

custom_components/battery_notes/coordinator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,11 @@ def last_reported(self) -> datetime | None:
667667
self.device_id
668668
)
669669

670-
if entry:
671-
if LAST_REPORTED in entry:
672-
if entry[LAST_REPORTED]:
673-
last_reported_date = datetime.fromisoformat(
674-
str(entry[LAST_REPORTED]) + "+00:00"
675-
)
676-
return last_reported_date
670+
if entry and LAST_REPORTED in entry and entry[LAST_REPORTED] is not None:
671+
entry_last_reported = str(entry[LAST_REPORTED])
672+
if not entry_last_reported.endswith("+00:00"):
673+
entry_last_reported += "+00:00"
674+
return datetime.fromisoformat(entry_last_reported)
677675

678676
return None
679677

0 commit comments

Comments
 (0)