schmittx / home-assistant-eero

Eero integration for Home Assistant
MIT License
118 stars 23 forks source link

Error: day is out of range for month #35

Closed pnichols77 closed 1 year ago

pnichols77 commented 2 years ago

This happens at the end of the month, with daily stats enabled. Matybe it's trying to look for 31st June for the current time period, which obviously doesn't exist.

Unexpected error fetching Eero (Phil Nichols) data: day is out of range for month
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/eero/__init__.py", line 176, in async_update_data
    return await hass.async_add_executor_job(api.update)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/eero/api/__init__.py", line 156, in update
    activity_data[resource][activity] = self.update_activity(
  File "/config/custom_components/eero/api/__init__.py", line 176, in update_activity
    start, end, cadence = self.define_period(period=ACTIVITY_MAP[activity][2], timezone=timezone)
  File "/config/custom_components/eero/api/__init__.py", line 69, in define_period
    end = start.replace(day=start.day+1) - datetime.timedelta(minutes=1)
ValueError: day is out of range for month
brian-gates commented 1 year ago

I see that a PR was merged in December, but I'm seeing this issue still today.

This error originated from a custom integration.

Logger: custom_components.eero
Source: custom_components/eero/api/__init__.py:73
Integration: eero (documentation, issues)
First occurred: 9:19:31 AM (1 occurrences)
Last logged: 9:19:31 AM

Unexpected error fetching Eero data: day is out of range for month
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/eero/__init__.py", line 185, in async_update_data
    return await hass.async_add_executor_job(api.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/eero/api/__init__.py", line 157, in update
    activity_data[resource][activity] = self.update_activity(
  File "/config/custom_components/eero/api/__init__.py", line 177, in update_activity
    start, end, cadence = self.define_period(period=ACTIVITY_MAP[activity][2], timezone=timezone)
  File "/config/custom_components/eero/api/__init__.py", line 73, in define_period
    start = now.replace(day=now.day-(now.weekday()+1), hour=0, minute=0, second=0, microsecond=0)
ValueError: day is out of range for month
schmittx commented 1 year ago

I believe this should be fixed now in 1.2 but let me know if there's still concerns.