home-assistant.io icon indicating copy to clipboard operation
home-assistant.io copied to clipboard

Fix example template sensor for weather.get_forecasts

Open jaydeethree opened this issue 1 year ago • 1 comments

Proposed change

There are two problems with this example:

  1. 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.

  2. 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 (current branch).
  • [x] Adjusted missing or incorrect information in the current documentation (current branch).
  • [ ] Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • [ ] Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • [ ] 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 current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • [x] The documentation follows the Home Assistant documentation standards.

jaydeethree avatar Feb 20 '24 19:02 jaydeethree

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 20 '24 19:02 netlify[bot]

Does this work if my weather service only updates every 3 hours or so?

c0ffeeca7 avatar Mar 15 '24 13:03 c0ffeeca7

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?

emontnemery avatar Mar 15 '24 14:03 emontnemery

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 avatar Mar 15 '24 23:03 jaydeethree

@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.

emontnemery avatar Mar 18 '24 09:03 emontnemery