Skip to content

Commit 6279445

Browse files
committed
Update circle too
1 parent d38368f commit 6279445

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,9 @@ async def clock_synchronize(self) -> bool:
880880
return False
881881

882882
dt_now = datetime.now(tz=UTC)
883-
days_diff = response.day_of_week.value - dt_now.weekday()
884-
circle_timestamp = dt_now.replace(
885-
day=dt_now.day - days_diff,
883+
days_diff = (response.day_of_week.value - dt_now.weekday()) % 7
884+
circle_plus_timestamp: datetime = dt_now.replace(
885+
day=dt_now.day + days_diff,
886886
hour=response.time.value.hour,
887887
minute=response.time.value.minute,
888888
second=response.time.value.second,
@@ -892,6 +892,7 @@ async def clock_synchronize(self) -> bool:
892892
clock_offset = response.timestamp.replace(microsecond=0) - circle_timestamp
893893
if abs(clock_offset.total_seconds()) < MAX_TIME_DRIFT:
894894
return True
895+
895896
_LOGGER.info(
896897
"Reset clock of node %s because time drifted %s seconds (max %s seconds)",
897898
self._mac_in_str,

0 commit comments

Comments
 (0)