Repository navigation
Description
Describe the bug.
The circle.clock_synchronize function calculates the drift in days by subtracting the weekday value reported by the circle from the current weekday, and adds that to the current day of the month:
python-plugwise-usb/plugwise_usb/nodes/circle.py
Lines 882 to 891 in f022c48
| dt_now = datetime.now(tz=UTC) | |
| days_diff = (response.day_of_week.value - dt_now.weekday()) % 7 | |
| circle_timestamp: datetime = dt_now.replace( | |
| day=dt_now.day + days_diff, | |
| hour=response.time.value.hour, | |
| minute=response.time.value.minute, | |
| second=response.time.value.second, | |
| microsecond=0, | |
| tzinfo=UTC, | |
| ) |
If the current day of the month is less than 7 days before the end of the month, this may lead to a day overflow.
For example, today is Tuesday January 27th. If a circle thinks that it's Monday then days_diff evaluates to 6, which leads to an invalid day of the month in day=dt_now.day + days_diff (27 + 6 = 33).
Expected behavior
The calculation should now overflow when the current day is close to the end of the month.
What version of Home Assistant Core has the issue?
2026.1.3
What type of installation are you running?
Home Assistant OS
How and which version of the integration do you have installed?
Home Assistant Core
What firmware version is your Plugwise product at?
2011-06-27
Home Assistant Logging (optional)
No response
Diagnostics information
2026-01-27 15:19:54.505 ERROR (MainThread) [custom_components.plugwise_usb.coordinator] Unexpected error fetching None data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 416, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 307, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/plugwise_usb/coordinator.py", line 77, in async_node_update
states = await self.node.get_state(features)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/plugwise_usb/nodes/circle.py", line 1246, in get_state
if not self._available and not await self.is_online():
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/plugwise_usb/nodes/node.py", line 583, in is_online
if not self._initialized and self._loaded and not await self.initialize():
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/plugwise_usb/nodes/circle.py", line 1008, in initialize
if not await self.clock_synchronize():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/plugwise_usb/nodes/circle.py", line 884, in clock_synchronize
circle_timestamp: datetime = dt_now.replace(
~~~~~~~~~~~~~~^
day=dt_now.day + days_diff,
^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
tzinfo=UTC,
^^^^^^^^^^^
)
^
ValueError: day is out of range for month
Additional information
No response
Activity
bouwew commentedon Jan 27, 2026
@jowiho Thanks for your bug-report.
Do you have any idea how large the offset is that causes this error?
Solve monthly overflow as reported in #399
jowiho commentedon Jan 27, 2026
@bouwew, I'm not sure to be honest because I don't know which
response.day_of_week.valuevalue this circle currently returns. But since today is the 27th I assume that the diff at least 5, sodt_now.day + days_diffbecomes at least 32. Today is Tuesday (weekday=1) so I expect that the circle either thinks that it's Sunday (weekday=6) or Monday (weekday=0) which would result in a diff of 5 or 6 respectively.Solve monthly overflow as reported in #399
[-][BUG]:[/-][+][BUG]: Day is out of range for month in clock_synchronize[/+]Merge pull request #400 from plugwise/fix-399
bouwew commentedon Jan 29, 2026
Fixed in v0.47.2, please update
plugwise-usb_betato v0.58.2 via HACS