Thank you so much for posting this. It’s the only one of all the code snippets in the multitude of threads about this issue that A) still works and 2) gives me the high for today, not the high for tomorrow or the high in the next 24 hours.
hi all,
looking ot get this working too. (to check on my cell phone what the actual temperaturen outside is and what it will be at the warmes point of the day - so I know what to wear
)
unfortunately this doesn’t work with me ?
I copied the code above in my configuration.yaml , but changed the name (since the met.no forecast sits in weather.forecast_thuis .
template:
- trigger:
- platform: state
entity_id: weather.forecast_thuis
action:
- variables:
w: weather.forecast_thuis
- service: weather.get_forecasts
data:
type: daily
target:
entity_id: '{{ w }}'
response_variable: r
sensor:
- name: 'Temperature Max'
unique_id: 'temperature_max'
unit_of_measurement: '°C'
device_class: temperature
state: "{{ r[w].forecast[0].temperature }}"
the template sensor (don’t know if I call it like that?) shows up between my entities:
but the values stays empty ![]()
every help is appreciated
Sorry @123 but I’m having the same issue.
Can I not just paste the code in the TEMPLATE EDITOR and it should run?
template:
- trigger:
- platform: state
entity_id: weather.home
action:
- variables:
w: weather.home
- service: weather.get_forecasts
data:
type: daily
target:
entity_id: '{{ w }}'
response_variable: r
sensor:
- name: 'Temperature Max'
unique_id: 'temperature_max'
unit_of_measurement: '°C'
device_class: temperature
state: "{{ r[w].forecast[0].temperature }}"
I get ‘r’ is undefined. Just pasted the example.
No.
The Template Editor is ised to test templates, not entire blocks of YAML. The Template Editor doesn’t process YAML.
I’m confused, where does this code go? Tried config.yml, template.yml, new automation.
The example is designed to be placed in the configuration.yaml file.
You may wish to review the documentation for the Template integration, specifically the section for YAML configuration.
If your configuration.yaml file contains something like this:
template: !include template.yaml
Then it means you have configured it to store Template entities in a separate file named template.yaml. In that case, the first line of the example containing the word template: should not be copy-pasted into the template.yaml file.
You’re using the Visual Studio Code add-on which includes Config Helper which adds validation features specific to Home Assistant.
One of those validation features is to identify invalid YAML syntax (as used specifically by Home Assistant). In the screenshot you posted, it is complaining about the use of platform: and service: in the example’s configuration.
It’s an old example (over a year old). It predates Home Assistant’s change from using the word platform: to trigger: and from the word service: to action:. In addition, the word trigger: was changed to its plural form triggers:.
The updated version looks like this:
template:
- triggers:
- trigger: state
entity_id: weather.home
action:
- variables:
w: weather.home
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: '{{ w }}'
response_variable: r
sensor:
- name: 'Temperature Max'
unique_id: 'temperature_max'
unit_of_measurement: '°C'
device_class: temperature
state: "{{ r[w].forecast[0].temperature }}"
NOTE
Home Assistant still supports the use of platform: and service: so it’s not absolutely necessary to update old examples. It’s only Config Helper, in Visual Studio Code, that identifies them as being problematic. However, if want to eliminate those red warning messages in Visual Studio Code then you’ll need to update the example.
You are amazing!! I will give that a try and let you know how it goes.
Okay, so now it’s working. Weird. Here is my code. Maybe I didn’t wait long enough for the update. Tks!
ttemplate:
- trigger:
- trigger: state
entity_id: weather.forecast_home
action:
- variables:
w: weather.forecast_home
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: "{{ w }}"
response_variable: r
sensor:
- name: "Temperature Max"
unique_id: "temperature_max"
unit_of_measurement: "°F"
device_class: temperature
state: "{{ r[w].forecast[0].temperature }}"
So this code 'works' but I don't actually get the forecasted high for the day, it's a moving high. Can you show me what it should be? @123
For instance, the high today was 83F but this result is 76. That's nearly what it is right now.
- trigger:
- trigger: state
entity_id: weather.forecast_home
action:
- variables:
w: weather.forecast_home
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: "{{ w }}"
response_variable: r
sensor:
- name: "Temperature Max"
unique_id: "temperature_max"
unit_of_measurement: "°F"
device_class: temperature
state: "{{ r[w].forecast[0].temperature }}"
Go to Settings -> Developer Tools -> Actions and run this action:
action: weather.get_forecasts
target:
entity_id: weather.forecast_home
data:
type: daily
Inspect the resulting data and find the forecasted maximum temperature for today. What is it?
Deutsche weather high is 80.6F (27c). Seems correct but it seems like it will change later. I will check it again later to see if it changes.
Here are 2 results. Shouldn't it be the same?
forecast:
- condition: sunny
datetime: "2026-05-28T10:00:00+00:00"
wind_bearing: 49.7
uv_index: 7.1
temperature: 80
templow: 58
wind_speed: 6.46
precipitation: 0
humidity: 39
- condition: sunny
- condition: sunny
datetime: "2026-05-28T10:00:00+00:00"
wind_bearing: 48.3
uv_index: 7.1
temperature: 79
templow: 65
wind_speed: 6.03
precipitation: 0
humidity: 42
Based on the results, it appears the weather forecaster you are using can periodically adjust their forecasted values.
I’m using Met.no. Isn’t this the built-in integration for HA?
Is there a way to restrict ‘daily’ to daily? Is there some other frequency option that you are aware of?
FYI, someone else has submitted a bug report indicating the Met.no integration is not reporting data correctly.
There are multiple weather provider integrations in core and even more available through custom integrations.
Change your trigger to a Time trigger so that it only fires once a day and quite a few more available through custom integrations.
Nothing... except maybe expecting a search for the word "Weather" to return things that don't have that word in them:
Not all of the integrations shown in the link I provided are weather providers... some are for weather station devices. The page doesn't have a way to narrow down the category to just provider integrations.
That is the Weather "Building Block" integration that all other weather-related integrations rely on... it isn't an integration you install directly yourself.
Doh! Obvious now!
I’ll take another look.



