pkissling / clock-weather-card

A Home Assistant Card indicating today's date/time, along with an iOS inspired weather forecast for the next days with animated icons
Other
398 stars 78 forks source link

New version not working with OpenWeatherMap #288

Closed zendiik closed 10 months ago

zendiik commented 10 months ago

Checklist:

Release with the issue:

Last working release (if known): 2.1.5

Browser and Operating System: Firefox Developer 120, Arch Linux

Description of problem: The card doesn't show up on the dashboard.

Javascript errors shown in the web inspector (if applicable):

Uncaught (in promise) Error: Weather entity "weather.openweathermap" does not support daily forecasts.

image

swampylee commented 10 months ago

Yep - even trying to downgrade back to previous version (and clearing cache) doesn't seem to fix it.

pkissling commented 10 months ago

hi there, what is your weather entity set to? daily or hourly?

image
zendiik commented 10 months ago

I have hourly image

pkissling commented 10 months ago

the error message is "weather entity does not support daily forecasts". can you set the entity to to daily then?

swampylee commented 10 months ago

If I change to daily in OpenWeatherMap that integration fails. Setting it back to hourly and it's fine (card still doesn't load though)

pkissling commented 10 months ago

i did some analysis to understand why this issue occurs:

until 2.1.6 clock-weather-card would always try to read first the forecast attribute available in the weather entity (despite the weather provider supporting the new weather.get_forecast and only if forecast was not available, it would use weather.get_forecast to obtain forecasts

image

in order to fix #218 i implemented a change (released with 2.1.6) so that clock-weather-card would rely on supported_features in the weather entity to either subscribe to forecast updates via weather.get_forecast or read it from forecast attribute in the weather entity.

this means that openweathermap is also affected by this change, as it provides the forecast attribute as part of the weather entity, but additionally supports the weather.get_forecast subscription. so since 2.1.6 clock-weather-card will try to subscribe to weather.get_forecast instead of reading it from the forecast attribute.

and here is the catch: in the free tier of openweathermap you are only able to subscribe to hourly forecasts. but with the default setup of clock-weather-card, you want to display the weather daily. so clock-weather-card will try to subscribe to daily updates, which is not supported by openweathermap. this is why you see the error

to fix the issue i will add some logic to make clock-weather-card fall back to hourly forecast subscription in case daily is not supported. i think this should fix your issue.

zendiik commented 10 months ago

Thank you