jwidess
(Justin W.)
June 30, 2025, 9:14pm
1
I have been losing my mind trying to figure out how to just get weather data into individual template sensors for use in other scripts and whatnot. I have gone through every post I can find on here and Reddit, and nothing has worked for me. I have successfully used the Weather: Get forecasts
action under the Dev Tools → Actions tab to request Pirateweather with the following YAML,
action: weather.get_forecasts
target:
entity_id:
- weather.pirateweather
data:
type: daily
And I get a good response like the following,
Summary
weather.pirateweather:
forecast:
- datetime: "2025-06-30T05:00:00+00:00"
condition: partlycloudy
precipitation_probability: 13
cloud_coverage: 45
wind_bearing: 270
temperature: 83
templow: 64
wind_gust_speed: 11.43
wind_speed: 5.53
precipitation: 0.02
humidity: 79
- datetime: "2025-07-01T05:00:00+00:00"
condition: sunny
precipitation_probability: 0
cloud_coverage: 7
wind_bearing: 303
temperature: 82
templow: 67
wind_gust_speed: 14.32
wind_speed: 7.2
precipitation: 0
humidity: 72
- datetime: "2025-07-02T05:00:00+00:00"
condition: sunny
precipitation_probability: 13
cloud_coverage: 14
wind_bearing: 272
temperature: 85
templow: 68
wind_gust_speed: 10.54
wind_speed: 5.12
precipitation: 0
humidity: 67
- datetime: "2025-07-03T05:00:00+00:00"
condition: sunny
precipitation_probability: 13
cloud_coverage: 23
wind_bearing: 229
temperature: 84
templow: 70
wind_gust_speed: 9.13
wind_speed: 3.85
precipitation: 0.02
humidity: 72
- datetime: "2025-07-04T05:00:00+00:00"
condition: partlycloudy
precipitation_probability: 13
cloud_coverage: 36
wind_bearing: 188
temperature: 89
templow: 75
wind_gust_speed: 14.43
wind_speed: 7.29
precipitation: 0.05
humidity: 73
- datetime: "2025-07-05T05:00:00+00:00"
condition: rainy
precipitation_probability: 42
cloud_coverage: 50
wind_bearing: 210
temperature: 86
templow: 72
wind_gust_speed: 19.73
wind_speed: 10.94
precipitation: 0.19
humidity: 74
- datetime: "2025-07-06T05:00:00+00:00"
condition: rainy
precipitation_probability: 54
cloud_coverage: 49
wind_bearing: 259
temperature: 83
templow: 68
wind_gust_speed: 14.12
wind_speed: 7.23
precipitation: 0.14
humidity: 81
- datetime: "2025-07-07T05:00:00+00:00"
condition: partlycloudy
precipitation_probability: 15
cloud_coverage: 48
wind_bearing: 246
temperature: 80
templow: 67
wind_gust_speed: 10.56
wind_speed: 5.01
precipitation: 0
humidity: 79
However, I cannot figure out how to template this data so I can extract it in other template sensors. No matter what I do, it always seems that the resulting sensor shows unavailable
for its state.
I recently found this comment by rossc719 which seemed promising as it’s only ~10 months old, however, I’ve had no luck with it. Below is my version of this template, but all of these sensors show as unavailable
Summary
- trigger:
- platform: time_pattern
minutes: 1
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.pirateweather
response_variable: daily
sensor:
- name: Forecast Today Condition
unique_id: forecast_today_condition
state: "{{ daily['weather.pirateweather'].forecast[0].condition }}"
icon: mdi:weather-partly-rainy
- name: Forecast Today Temperature
unique_id: forecast_today_temperature
state: "{{ daily['weather.pirateweather'].forecast[0].temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Low Temperature
unique_id: forecast_today_templow
state: "{{ daily['weather.pirateweather'].forecast[0].templow }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Humidity
unique_id: forecast_today_humidity
state: "{{ daily['weather.pirateweather'].forecast[0].humidity }}"
unit_of_measurement: "%"
device_class: humidity
- name: Forecast Today Cloud Cover
unique_id: forecast_today_cloud_cover
state: "{{ daily['weather.pirateweather'].forecast[0].cloud_coverage }}"
unit_of_measurement: "%"
icon: mdi:cloud
- name: Forecast Today Precipitation
unique_id: forecast_today_precipitation
state: "{{ daily['weather.pirateweather'].forecast[0].precipitation }}"
unit_of_measurement: in
icon: mdi:water
- name: Forecast Today Wind Bearing
unique_id: forecast_today_wind_bearing
state: "{{ daily['weather.pirateweather'].forecast[0].wind_bearing }}"
unit_of_measurement: °
icon: mdi:compass
- name: Forecast Today Wind Speed
unique_id: forecast_today_wind_speed
state: "{{ daily['weather.pirateweather'].forecast[0].wind_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
- name: Forecast Today Wind Gust Speed
unique_id: forecast_today_wind_gust_speed
state: "{{ daily['weather.pirateweather'].forecast[0].wind_gust_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
If anyone knows what I’m doing wrong or how I can simply get some of these variables, like the forecasted high, low, and chance of rain, I would greatly appreciate it!
Where are you putting this configuration?
jwidess:
hours: /60
The states won’t have values until one of the triggers fires, and your time pattern trigger is never going to fire… so that just leaves restart and posting your custom event. Have you restarted HA or posted the event using the Events tools in the Developer Tools menu?
jwidess
(Justin W.)
June 30, 2025, 9:32pm
3
Sorry that was leftover from testing, I actually have the following in the config:
- trigger:
- platform: time_pattern
minutes: 1
And I am placing this in my templates.yaml
file which has other template sensors that work fine. And yes I have restarted HA many times.
rossc719
(Charlie Ross)
June 30, 2025, 11:42pm
4
Since I wrote my initial comment, I did a bit of work on my end. My setup now looks like this:
weather.yaml
template:
- sensor:
- name: "Accuweather Temperature"
unique_id: accuweather_temperature
state: "{{ state_attr('weather.home', 'temperature') }}"
unit_of_measurement: °F
device_class: temperature
- trigger:
- platform: time_pattern
hours: /1
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.home
response_variable: daily
sensor:
- name: Forecast Today Condition
unique_id: forecast_today_condition
state: "{{ daily['weather.home'].forecast[0].condition }}"
icon: mdi:weather-partly-rainy
- name: Forecast Today Temperature
unique_id: forecast_today_temperature
state: "{{ daily['weather.home'].forecast[0].temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Low Temperature
unique_id: forecast_today_templow
state: "{{ daily['weather.home'].forecast[0].templow }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Apparent Temperature
unique_id: forecast_today_high_apparent_temperature
state: "{{ daily['weather.home'].forecast[0].apparent_temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Humidity
unique_id: forecast_today_humidity
state: "{{ daily['weather.home'].forecast[0].humidity }}"
unit_of_measurement: "%"
device_class: humidity
- name: Forecast Today Cloud Cover
unique_id: forecast_today_cloud_cover
state: "{{ daily['weather.home'].forecast[0].cloud_coverage }}"
unit_of_measurement: "%"
icon: mdi:cloud
- name: Forecast Today Precipitation Probability
unique_id: forecast_today_precipitation_probability
state: "{{ daily['weather.home'].forecast[0].precipitation_probability }}"
unit_of_measurement: "%"
icon: mdi:water-percent
- name: Forecast Today Precipitation
unique_id: forecast_today_precipitation
state: "{{ daily['weather.home'].forecast[0].precipitation }}"
unit_of_measurement: in
icon: mdi:water
- name: Forecast Today UV Index
unique_id: forecast_today_uv_index
state: "{{ daily['weather.home'].forecast[0].uv_index }}"
unit_of_measurement: "UV index"
icon: mdi:sun-wireless
- name: Forecast Today Wind Bearing
unique_id: forecast_today_wind_bearing
state: "{{ daily['weather.home'].forecast[0].wind_bearing }}"
unit_of_measurement: °
icon: mdi:compass
- name: Forecast Today Wind Speed
unique_id: forecast_today_wind_speed
state: "{{ daily['weather.home'].forecast[0].wind_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
- name: Forecast Today Wind Gust Speed
unique_id: forecast_today_wind_gust_speed
state: "{{ daily['weather.home'].forecast[0].wind_gust_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
- name: Forecast Tomorrow Condition
unique_id: forecast_tomorrow_condition
state: "{{ daily['weather.home'].forecast[1].condition }}"
icon: mdi:weather-partly-rainy
- name: Forecast Tomorrow Temperature
unique_id: forecast_tomorrow_temperature
state: "{{ daily['weather.home'].forecast[1].temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Tomorrow Low Temperature
unique_id: forecast_tomorrow_templow
state: "{{ daily['weather.home'].forecast[1].templow }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Tomorrow Apparent Temperature
unique_id: forecast_tomorrow_high_apparent_temperature
state: "{{ daily['weather.home'].forecast[1].apparent_temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Tomorrow Humidity
unique_id: forecast_tomorrow_humidity
state: "{{ daily['weather.home'].forecast[1].humidity }}"
unit_of_measurement: "%"
device_class: humidity
- name: Forecast Tomorrow Cloud Cover
unique_id: forecast_tomorrow_cloud_cover
state: "{{ daily['weather.home'].forecast[1].cloud_coverage }}"
unit_of_measurement: "%"
icon: mdi:cloud
- name: Forecast Tomorrow Precipitation Probability
unique_id: forecast_tomorrow_precipitation_probability
state: "{{ daily['weather.home'].forecast[1].precipitation_probability }}"
unit_of_measurement: "%"
icon: mdi:water-percent
- name: Forecast Tomorrow Precipitation
unique_id: forecast_tomorrow_precipitation
state: "{{ daily['weather.home'].forecast[1].precipitation }}"
unit_of_measurement: in
icon: mdi:water
- name: Forecast Tomorrow UV Index
unique_id: forecast_tomorrow_uv_index
state: "{{ daily['weather.home'].forecast[1].uv_index }}"
unit_of_measurement: "UV index"
icon: mdi:sun-wireless
- name: Forecast Tomorrow Wind Bearing
unique_id: forecast_tomorrow_wind_bearing
state: "{{ daily['weather.home'].forecast[1].wind_bearing }}"
unit_of_measurement: °
icon: mdi:compass
- name: Forecast Tomorrow Wind Speed
unique_id: forecast_tomorrow_wind_speed
state: "{{ daily['weather.home'].forecast[1].wind_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
- name: Forecast Tomorrow Wind Gust Speed
unique_id: forecast_tomorrow_wind_gust_speed
state: "{{ daily['weather.home'].forecast[1].wind_gust_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
“weather.home” is the name of my accuweatrher entity for my house. You might need to adjust to use yours. I have no idea if it would work on any other weather provider’s data.
jwidess
(Justin W.)
July 1, 2025, 12:28am
5
Thanks @rossc719 , well, I have no idea what I changed, but now it seems to be working fine! I could have sworn I set the trigger interval to 1 minute before making sure it was updating, but whatever the case, thanks for the help all! Below is my current template.yaml
template.yaml
- trigger:
- platform: time_pattern
hours: /1
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.pirateweather
response_variable: daily
sensor:
- name: Forecast Today Condition
unique_id: forecast_today_condition
state: "{{ daily['weather.pirateweather'].forecast[0].condition }}"
icon: mdi:weather-partly-rainy
- name: Forecast Today Temperature
unique_id: forecast_today_temperature
state: "{{ daily['weather.pirateweather'].forecast[0].temperature }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Low Temperature
unique_id: forecast_today_low_temp
state: "{{ daily['weather.pirateweather'].forecast[0].templow }}"
unit_of_measurement: °F
device_class: temperature
- name: Forecast Today Humidity
unique_id: forecast_today_humidity
state: "{{ daily['weather.pirateweather'].forecast[0].humidity }}"
unit_of_measurement: "%"
device_class: humidity
- name: Forecast Today Cloud Cover
unique_id: forecast_today_cloud_cover
state: "{{ daily['weather.pirateweather'].forecast[0].cloud_coverage }}"
unit_of_measurement: "%"
icon: mdi:cloud
- name: Forecast Today Precipitation Probability
unique_id: forecast_today_precipitation_probability
state: "{{ daily['weather.pirateweather'].forecast[0].precipitation_probability }}"
unit_of_measurement: "%"
icon: mdi:water-percent
- name: Forecast Today Precipitation
unique_id: forecast_today_precipitation
state: "{{ daily['weather.pirateweather'].forecast[0].precipitation }}"
unit_of_measurement: in
icon: mdi:water
- name: Forecast Today Wind Bearing
unique_id: forecast_today_wind_bearing
state: "{{ daily['weather.pirateweather'].forecast[0].wind_bearing }}"
unit_of_measurement: °
icon: mdi:compass
- name: Forecast Today Wind Speed
unique_id: forecast_today_wind_speed
state: "{{ daily['weather.pirateweather'].forecast[0].wind_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
- name: Forecast Today Wind Gust Speed
unique_id: forecast_today_wind_gust_speed
state: "{{ daily['weather.pirateweather'].forecast[0].wind_gust_speed }}"
unit_of_measurement: mph
icon: mdi:weather-windy
# Payload e.g.: HIGH:84,LOW:64,TEMP:85,RAIN:10.0,HUM:50,TIME:5:36 PM,DATE:Monday - Jun 30,DATETXT:6/30/2025,CLOUD:partlycloudy
- sensor:
- name: "UART Weather Payload"
unique_id: uart_weather_payload
state: >-
{{
"HIGH:" ~ (states('sensor.forecast_today_temperature') if states('sensor.forecast_today_temperature') not in ['unavailable', 'unknown'] else '0') ~
",LOW:" ~ (states('sensor.forecast_today_low_temperature') if states('sensor.forecast_today_low_temperature') not in ['unavailable', 'unknown'] else '0') ~
",TEMP:" ~ (state_attr('weather.forecast_home', 'temperature') | int) ~
",RAIN:" ~ (states('sensor.forecast_today_precipitation_probability') if states('sensor.forecast_today_precipitation_probability') not in ['unavailable', 'unknown'] else '0') ~
",HUM:" ~ (state_attr('weather.forecast_home', 'humidity') | int) ~
",TIME:" ~ now().strftime('%-I:%M %p') ~
",DATE:" ~ now().strftime('%A - %b %-d') ~
",DATETXT:" ~ now().strftime('%-m/%-d/%Y') ~
",CLOUD:" ~ (states('sensor.forecast_today_condition') if states('sensor.forecast_today_condition') not in ['unavailable', 'unknown'] else 'clear')
}}
That includes a template device at the end for a project I’m working on that uses ESPHome to write that “payload” to UART.
rossc719
(Charlie Ross)
July 1, 2025, 1:49am
6
Ah, that might have been the issue.
IIRC, these weather services have a throttle of something (iirc) like 30 a day or something. I think I remember it being enough to do 1 per hour, plus a few tests… but anything more than that, you run out quickly and it stops working until you get your next batch of 30 the next day.
TheFes
(The Fes)
July 1, 2025, 8:02am
7
It depends a bit on the integration, but normally it should not use an API call when you use the weather.get_forecasts
action, but it should use the data already available. So calling the action should have no effect on reaching the API limit.
That is an interesting comment, why would it have data available but not show it in the entity as attributes (like it did about 2y ago)? And then ‘where’ would it be available/stored?
TheFes
(The Fes)
July 1, 2025, 8:57am
9
The same place as it stores the data to show the forecast on the dashboard or the entity more info dialog. I do not know where that is, but it doesn’t use an API call to request a new forecast every time you open your dashboard.
My previous comment is based on the information shared at the time the attribute was removed. I don’t have the background knowledge to explain how it works.
Here’s an example: [PETITION] Don't delete the forecast attribute - #27 by petro
OK, thanks… I remain curious as to why it would not show in the entity if it is already stored ‘somewhere’ in HA, esp. as removing this from the entity created all sorts of stuff …anyhow, choices by devs
petro
(Petro)
July 1, 2025, 11:35am
11
HA has been moving away from attributes towards devices & entities for a number of reasons. Ease of use in the UI, database optimization, statistics, etc.
There are drawbacks to moving that direction, and weather forecast is one of the drawbacks.
1 Like
Oh my gosh, thank you so much! I have been struggling with this for so many hours and I just copied and pasted this into configuration.yaml and now it works!
1 Like