home-assistant.io
home-assistant.io copied to clipboard
Fix example template sensor for weather.get_forecasts
Proposed change
There are two problems with this example:
-
Using a time-based trigger here will cause Home Assistant to log an error. See https://github.com/home-assistant/core/issues/99914 for details.
-
It makes more sense to update the template sensor when the weather entity or its attributes change, instead of updating it on a fixed schedule.
Type of change
- [ ] Spelling, grammar or other readability improvements (
currentbranch). - [x] Adjusted missing or incorrect information in the current documentation (
currentbranch). - [ ] Added documentation for a new integration I'm adding to Home Assistant (
nextbranch).- [ ] I've opened up a PR to add logos and icons in Brands repository.
- [ ] Added documentation for a new feature I'm adding to Home Assistant (
nextbranch). - [ ] Removed stale or deprecated documentation.
Additional information
- Link to parent pull request in the codebase:
- Link to parent pull request in the Brands repository:
- This PR fixes or closes issue: fixes #
Checklist
- [x] This PR uses the correct branch, based on one of the following:
- I made a change to the existing documentation and used the
currentbranch. - I made a change that is related to an upcoming version of Home Assistant and used the
nextbranch.
- I made a change to the existing documentation and used the
- [x] The documentation follows the Home Assistant documentation standards.
Deploy Preview for home-assistant-docs ready!
| Name | Link |
|---|---|
| Latest commit | 7d6e76e12150713f3b8d473c37773c3d898713de |
| Latest deploy log | https://app.netlify.com/sites/home-assistant-docs/deploys/65d8ed9760227100086734fc |
| Deploy Preview | https://deploy-preview-31518--home-assistant-docs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Does this work if my weather service only updates every 3 hours or so?
The PR description states:
Using a time-based trigger here will cause Home Assistant to log an error. See https://github.com/home-assistant/core/issues/99914 for details.
That seems to be a bug, which we should fix, not hide by changing this example.
It makes more sense to update the template sensor when the weather entity or its attributes change, instead of updating it on a fixed schedule.
Why does this makes sense? What does the weather entity's state have to do with the forecast?
That seems to be a bug, which we should fix, not hide by changing this example.
That's fair.
Why does this makes sense? What does the weather entity's state have to do with the forecast?
Since the weather entity contains the forecast data, I would expect that both the forecast data and the weather entity's state/attributes would all be updated at the same time. Perhaps that's not actually true though? That's how I do it in my weather integration, but maybe other integrations work differently (in which case I agree that this doesn't make sense).
@jaydeethree the weather entity was recently updated to deprecate the forecast property from the state attributes as documented in this blog post: https://developers.home-assistant.io/blog/2023/08/07/weather_entity_forecast_types, that means there may not be a state change when the forecast is updated.