home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.95k stars 29.61k forks source link

OpenWeatherMap: weather entity lacks an attribute containing timestamp of forecasts generated or last cache update #121595

Open veitw opened 1 month ago

veitw commented 1 month ago

The problem

Currently it is required to poll forecasts at intervals from the weather entity to reflect new forecast data after the integration has updated and cached new data.

The entity attributes only contain information about the current weather. While the current weather data usually changes with an update, this is not guaranteed, thus a state trigger cannot be used to reliably detect forecast changes.

Adding a forecasts_as_of timestamp attribute if available from OpenWeatherMap's API, or else a last_cache_update timestamp attribute, would fire state triggers and allow immediate processing of new forecast data even if current weather has not changed.

What version of Home Assistant Core has the issue?

core-2024.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OpenWeatherMap

Link to integration documentation on our website

https://www.home-assistant.io/integrations/openweathermap/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @fabaff, @freekode, @nzapponi, mind taking a look at this issue as it has been labeled with an integration (openweathermap) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `openweathermap` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign openweathermap` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


openweathermap documentation openweathermap source (message by IssueLinks)

mciantar commented 3 weeks ago

Up until version 2.5, I was able to get sensor.openweathermap_forecast_precipitation, but since the migration to 3.0, I do not seem to have this option. How can I retrieve the forecast_precipitation from this integration, please?

veitw commented 3 weeks ago

Hey @mciantar ,

Up until version 2.5, I was able to get sensor.openweathermap_forecast_precipitation, but since the migration to 3.0, I do not seem to have this option. How can I retrieve the forecast_precipitation from this integration, please?

this is caused by something different; HA 2024.7 removed the forecast entities. Instead you have to use the weather.get_forecasts service now. The alternative is to create template sensors for these entities.

I did a tutorial on how to emulate all removed entities using templates, just take care to replace all occurrences of weather.home by your OpenWeatherMap weather. entity_id.

Find the English version here: https://schoen-technisch.de/en/homeassistant-2024-7-emulating-obsoleted-weather-forecast-entities-using-template-sensors/

Or the German original here: https://schoen-technisch.de/homeassistant-2024-7-weggefallene-wettervorhersage-entitaeten-mittels-template-sensoren-emulieren/

Best regards // Veit

mciantar commented 3 weeks ago

@veitw , Thank you very much for understanding my issue and pointing me not just in the right direction, but also providing a working example. I have managed to get my forecast sensor working again thanks to your help.