briis / smartweather

WeatherFlow Smart Weather Component for Home Assistant
MIT License
110 stars 11 forks source link

can't compare datetime.datetime to datetime.date #68

Closed verstrepeng closed 3 years ago

verstrepeng commented 3 years ago

After upgrading via HACS to the latest version, my integration is broken. In the logs following error:

Logger: custom_components.smartweather
Source: helpers/update_coordinator.py:143
Integration: WeatherFlow Smart Weather (documentation, issues)
First occurred: 15:27:54 (2 occurrences)
Last logged: 15:38:32

Unexpected error fetching smartweather data: can't compare datetime.datetime to datetime.date
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in _async_update_data
    return await self.update_method()
  File "/usr/local/lib/python3.8/site-packages/pysmartweatherio/client.py", line 109, in get_hourly_forecast
    return await self._forecast_data(FORECAST_TYPE_HOURLY, 72)
  File "/usr/local/lib/python3.8/site-packages/pysmartweatherio/client.py", line 402, in _forecast_data
    if today > forecast_time:
TypeError: can't compare datetime.datetime to datetime.date
briis commented 3 years ago

I made a quick fix that should solve the problem:

Could you edit the file manifest.json in custom_components/smartweather and change this:

    "requirements": [
        "pysmartweatherio==2.1.8"
    ]

to this:

    "requirements": [
        "pysmartweatherio==2.1.9"
    ]

Restart Home Assistant, and see if it works?

verstrepeng commented 3 years ago

You rock ! It is working again :-)

alexdelprete commented 3 years ago

Had the exact same issue, I just upgraded, and can confirm the fix works.

Thanks Bjarne.

briis commented 3 years ago

Perfect. I will release the fix to HACS now.