Skip to content

Update template weather docs because of removal of forecast attribute #32163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: current
Choose a base branch
from

Conversation

TheFes
Copy link
Contributor

@TheFes TheFes commented Apr 4, 2024

Proposed change

The old example was still referring to the forecast attribute of a weather entity. It also still had forecast_template in the configuration variables, which is no longer working.
I also added an example on how to create a template sensor with the forecast.

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • 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

  • 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.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • Documentation
    • Enhanced configuration instructions for the weather provider.
    • Clarified where configuration variables should be updated.
    • Updated the method for accessing daily forecast data.
    • Added an example YAML configuration for a trigger-based sensor that updates every three hours.
    • Removed an outdated configuration entry for a more streamlined setup.

@home-assistant home-assistant bot added the current This PR goes into the current branch label Apr 4, 2024
Copy link

netlify bot commented Apr 4, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit cef42fc
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/660ec9f7abc06d000898b0b3
😎 Deploy Preview https://deploy-preview-32163--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.

Comment on lines +42 to +67
If you want to use the forecast of another weather integration, you'll need to create a trigger based template sensor and store the forecast in an attribute.
This is an example on how you can create such a sensor which will update every 3 hours.

{% raw %}

```yaml
# Example configuration.yaml entry
template:
- trigger:
- platform: time_pattern
hours: "/3"
action:
- service: weather.get_forecasts
target:
entity_id: weather.my_region
data:
type: daily
response_variable: forecast
sensor:
- unique_id: daily_weather_forecast_template_sensor
name: Daily Weather Forecast
state: "{{ now() }}"
attributes:
forecast: "{{ forecast['weather.my_region'].forecast }}"
```
{% endraw %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically re-creating what we wanted to get rid off. I don't think it makes sense to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.

My main goal was to remove the reference to state_attr('weather.my_region', 'forecast') as that was no longer possible.
But if you do want to add a forecast to a template weather, it has to come from somewhere, that's why I added it.

I can remove that part, and leave it to the end user how they get the data for the <type>_forecast_templates.

@TheFes
Copy link
Contributor Author

TheFes commented Apr 8, 2024

@frenck as the template weather now works with the modern template format, shouldn't this page just be removed (and linked to the template docs, like eg also happens with https://home-assistant.io/components/binary_sensor.template/)?

It should also be removed from the list with integrations still using the legacy format at the top of this page https://www.home-assistant.io/integrations/template/

@frenck frenck self-assigned this May 27, 2024
@frenck frenck self-requested a review May 27, 2024 07:54
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the Stale The PR had no activity for quite some time, and is marked as Stale label Mar 14, 2025
Copy link
Contributor

coderabbitai bot commented Mar 14, 2025

📝 Walkthrough

Walkthrough

This update revises the Template Weather provider documentation. The changes clarify that the my_region variable must be updated in both the configuration condition and the sensor configuration. It also updates the daily forecast reference from weather.my_region to sensor.daily_weather_forecast and adds a YAML example for a trigger-based template sensor that updates every three hours. Additionally, the configuration option forecast_template has been removed.

Changes

File Change Summary
source/_integrations/.../weather.template.markdown - Clarified note on updating the my_region variable in both condition and sensor configurations.
- Updated forecast_daily_template from weather.my_region to sensor.daily_weather_forecast.
- Added YAML example for a trigger-based template sensor (updates every three hours).
- Removed the forecast_template configuration entry.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler as 3hr Scheduler
    participant Sensor as Template Sensor
    participant Forecast as Daily Forecast Provider

    Scheduler->>Sensor: Trigger sensor update every 3 hours
    Sensor->>Forecast: Request forecast via sensor.daily_weather_forecast
    Forecast-->>Sensor: Return forecast data
    Sensor-->>Scheduler: Update sensor state with new forecast
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
source/_integrations/weather.template.markdown (4)

24-24: Clarify the 'my_region' Note

The note instructs users to update my_region in both the template weather condition and the corresponding template sensor configuration. Consider rephrasing it for enhanced clarity. For example:

Note: Ensure that you update the my_region placeholder in both the condition template and the template sensor configuration to match your setup.


42-44: Enhance Wording in the Sensor Trigger Example

The current phrasing—"trigger based template sensor" and "an example on how you can create such a sensor"—can be improved for clarity and grammatical correctness. Consider revising it to:

If you want to use the forecast from another weather integration, you'll need to create a trigger-based template sensor and store the forecast in an attribute. This is an example of how you can create such a sensor, which will update every 3 hours.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~42-~42: This expression is usually spelled with a hyphen.
Context: ...er integration, you'll need to create a trigger based template sensor and store the forecast ...

(BASED_HYPHEN)


[uncategorized] ~43-~43: The preposition “of” seems more likely in this position.
Context: ...ast in an attribute. This is an example on how you can create such a sensor which ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)


45-67: Adhere to Markdownlint Guidelines for Fenced Code Blocks

The fenced YAML code block in this section should be surrounded by blank lines to conform with markdownlint MD031. Please ensure there is a blank line before the opening yaml and after the closing to improve readability and compliance.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

66-66: Fenced code blocks should be surrounded by blank lines
null

(MD031, blanks-around-fences)


65-65: Verify Forecast Key Consistency

The YAML example uses the expression {{ forecast['weather.my_region'].forecast }}. Make sure that this reference is consistent with the updated configuration instructions. It might be helpful to remind users that they should replace 'weather.my_region' with their actual weather entity ID if it differs from the placeholder.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e614e4 and cef42fc.

📒 Files selected for processing (1)
  • source/_integrations/weather.template.markdown (2 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/weather.template.markdown

[uncategorized] ~42-~42: This expression is usually spelled with a hyphen.
Context: ...er integration, you'll need to create a trigger based template sensor and store the forecast ...

(BASED_HYPHEN)


[uncategorized] ~43-~43: The preposition “of” seems more likely in this position.
Context: ...ast in an attribute. This is an example on how you can create such a sensor which ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

🪛 markdownlint-cli2 (0.17.2)
source/_integrations/weather.template.markdown

66-66: Fenced code blocks should be surrounded by blank lines
null

(MD031, blanks-around-fences)

🔇 Additional comments (1)
source/_integrations/weather.template.markdown (1)

37-37: Confirm Updated Forecast Reference

The change from referencing weather.my_region to sensor.daily_weather_forecast for forecast_daily_template correctly reflects the updated data source. This aligns with the overall update of the configuration.

@github-actions github-actions bot removed the Stale The PR had no activity for quite some time, and is marked as Stale label Mar 14, 2025
Copy link

github-actions bot commented Jul 1, 2025

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the Stale The PR had no activity for quite some time, and is marked as Stale label Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
current This PR goes into the current branch Stale The PR had no activity for quite some time, and is marked as Stale
Projects
No open projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

The example for forecast_daily_template in the Weather Template documentation is not valid
2 participants