Update from using weather attributes with the new service: weather.get_forecasts

Edit [September 21, 2025]: This guide has been updated to reflect the new weather.get_forecasts service and to provide a more robust solution for both hourly and daily forecasts. It also includes notes on common issues with weather provider integrations.

Hello everyone,

Home Assistant has changed the way it provides weather forecast data. The old method of reading the forecast directly from a weather entity’s attributes is no longer supported. This will cause openHASP panels that display future forecasts to show blank or incorrect data.

This guide will walk you through the new, correct method.

Two screen shots of the basic old way weather is shows and the new templates that will show more details of daily and or hourly weather.
Before


After


Important Note on Weather Integrations (like AccuWeather)

Many users have reported ongoing issues with the official AccuWeather integration in Home Assistant. Common problems include the weather entity frequently becoming unavailable or failing to update, which can cause your weather display to appear broken even if your templates are correct.

If you are experiencing these issues, I strongly recommend switching to the built-in Met.no integration. It is the default weather provider for Home Assistant and is known to be very stable and reliable. The examples in this guide will use the default weather.home entity created by Met.no.


Step 1: Create the New Weather Forecast Sensors

You need to add the following code to your template.yaml file (or wherever you store your template sensor configurations). This will create two new sensors: sensor.weather_hourly_forecast and sensor.weather_daily_forecast.

Important: In the code below, you must replace weather.home with the actual name of your weather entity (e.g., weather.accuweather if yours is working, or weather.home if you are using Met.no). You can find your entity ID in Settings > Devices & Services > Entities.

Add this code to your template.yaml file

yaml
# Sensor to fetch and store the HOURLY weather forecast
- trigger:
    - platform: time_pattern
      minutes: "/30" # Update every 30 minutes
    - platform: homeassistant
      event: start
  action:
    - service: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.home # <-- CHANGE THIS to your weather entity
      response_variable: hourly
  sensor:
    - name: "Weather Hourly Forecast"
      unique_id: weather_hourly_forecast
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.home'].forecast }}" # <-- CHANGE THIS to match

# Sensor to fetch and store the DAILY weather forecast
- trigger:
    - platform: time_pattern
      hours: "/1" # Update every hour
    - platform: homeassistant
      event: start
  action:
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.home # <-- CHANGE THIS to your weather entity
      response_variable: daily
  sensor:
    - name: "Weather Daily Forecast"
      unique_id: weather_daily_forecast
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ daily['weather.home'].forecast }}" # <-- CHANGE THIS to match

A Note on Update Times

In the code above, the hourly forecast updates every 30 minutes (minutes: "/30") and the daily forecast updates every hour (hours: "/1"). You can adjust these values to your liking. For testing, you might want to temporarily set it to update every minute (minutes: "/1") to see your changes quickly, then change it back to a longer interval later to avoid putting unnecessary load on the weather service.


Understanding the Forecast: forecast[0], forecast[1], etc.

A common point of confusion is how to get the forecast for a specific hour or day. The forecast attribute is a list, and in programming, lists always start counting from zero.

Hourly Forecast (sensor.weather_hourly_forecast)

  • forecast[0] = The current hour
  • forecast[1] = 1 hour from now
  • forecast[2] = 2 hours from now
  • …and so on.

Daily Forecast (sensor.weather_daily_forecast)

  • forecast[0] = Today
  • forecast[1] = Tomorrow
  • forecast[2] = The day after tomorrow
  • …and so on.

Practical Example

So, when you see a template in your openhasp.yaml file like this:
yaml

# This gets the high temperature for tomorrow:
"{{ state_attr('sensor.weather_daily_forecast','forecast')[1].temperature }}"


Step 1b: Using Your New Forecast Sensors

Now that you have sensors that hold the forecast data, you can use them in all sorts of useful ways around Home Assistant. Here are a couple of common examples.

Example 1: Dashboard Weather Card

You can use the new sensor.weather_daily_forecast with the standard Home Assistant Weather Forecast Card for a clean daily forecast on your dashboard.

  1. On your dashboard, click “Add Card”.
  2. Search for and select the Weather Forecast card.
  3. For the main “Entity”, choose your original weather entity (e.g., weather.home).
  4. Check the box for “Secondary Info Entity” and select your new sensor.weather_daily_forecast.

Card YAML:
yaml

type: weather-forecast
entity: weather.home
show_forecast: true
secondary_info_entity: sensor.weather_daily_forecast

Example 2: “Good Morning” Automation

This is a common automation where your smart speaker tells you the forecast for the day when you wake up. This example uses the new sensor.weather_daily_forecast to get the high temperature and condition for today.

Automation YAML:

- alias: "Good Morning Weather Announcement"
  id: good_morning_weather_announcement
  trigger:
    # Trigger this however you like, e.g., when you turn off your alarm
    - platform: state
      entity_id: input_boolean.wake_up
      to: 'on'
  action:
    # This creates variables to make the message easier to read
    - variables:
        todays_forecast: "{{ state_attr('sensor.weather_daily_forecast', 'forecast')[0] }}"
        high_temp: "{{ todays_forecast.temperature }}"
        condition: "{{ todays_forecast.condition | replace('-', ' ') }}"
    # This sends the message to a smart speaker
    - service: tts.google_say
      target:
        entity_id: media_player.living_room_speaker #<-- Change to your speaker
      data:
        message: >
          Good morning! The forecast for today is {{ condition }},
          with a high of {{ high_temp }} degrees.

Step 2: Update Your openHASP Configuration

Now, you need to edit your openhasp.yaml file to tell your display to get its forecast data from these new sensors. You will need to find all the objects related to your weather page and change the templates.

Example for an hourly forecast object:

  • OLD CODE:
    - obj: "p5b22" # Forecast temp +1h
      properties:
        "text": "{{ state_attr('weather.home','forecast')[1]['temperature'] }}"
    
  • NEW CODE:
    - obj: "p5b22" # Forecast temp +1h
      properties:
        "text": "{{ state_attr('sensor.weather_hourly_forecast','forecast')[1].temperature }}"
    

Example for a daily forecast object:

  • OLD CODE:
    - obj: "p5b63" # Forecast temp max +1d
      properties:
        "text": "{{ state_attr('weather.home','forecast')[1]['temperature'] }}"
    
  • NEW CODE:
    - obj: "p5b63" # Forecast temp max +1d
      properties:
        "text": "{{ state_attr('sensor.weather_daily_forecast','forecast')[1].temperature }}"
    

Step 3: Restart Home Assistant

After saving both your template.yaml and your openhasp.yaml files, you must restart Home Assistant for the changes to take effect.

Once restarted, your new sensors will be created, and your openHASP weather page should display all the forecast information correctly. You can verify that your new sensors are working by checking them in Developer Tools > States.


Alternative Method: Creating Individual Template Sensors

The main guide shows how to create a single sensor that stores the entire forecast in an attribute. This is very powerful and efficient. However, some users may prefer to have individual sensors for each piece of data they need (e.g., a sensor just for today’s high temperature, or a sensor for tomorrow’s condition).

This method can be useful if you only need a few specific forecast values and prefer to have them as separate, simple entities.

Here is an example of how you could create a few individual sensors for today’s and tomorrow’s forecast in your template.yaml file.

# Add this code to your template.yaml file for individual sensors
- trigger:
    - platform: time_pattern
      hours: "/1"
    - platform: homeassistant
      event: start
  action:
    # Get the daily forecast and store it in a variable
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.home # <-- CHANGE THIS to your weather entity
      response_variable: daily
    # Create variables for today's and tomorrow's forecast for easier use
    - variables:
        today: "{{ daily['weather.home'].forecast[0] }}"
        tomorrow: "{{ daily['weather.home'].forecast[1] }}"
  sensor:
    # --- Sensors for Today's Forecast ---
    - name: "Forecast High Temp Today"
      unique_id: forecast_high_temp_today
      state: "{{ today.temperature }}"
      unit_of_measurement: "°F"
    - name: "Forecast Low Temp Today"
      unique_id: forecast_low_temp_today
      state: "{{ today.templow }}"
      unit_of_measurement: "°F"
    - name: "Forecast Condition Today"
      unique_id: forecast_condition_today
      state: "{{ today.condition }}"

    # --- Sensors for Tomorrow's Forecast ---
    - name: "Forecast High Temp Tomorrow"
      unique_id: forecast_high_temp_tomorrow
      state: "{{ tomorrow.temperature }}"
      unit_of_measurement: "°F"
    - name: "Forecast Condition Tomorrow"
      unique_id: forecast_condition_tomorrow
      state: "{{ tomorrow.condition }}"

Sources & Further Reading

My Project & Sources

For more on my personal openHASP project, you can check out my main forum thread and my GitHub repository.

4 Likes

Thanks for the heads-up. I didn’t see this before, even though apparently it’s been deprecated for a while.

I’ve made a note to check my weather displays when I update to 2024.3.x. Frankly HA isn’t my primary source for weather information, so it’s not that big a deal for me. I do use outside temp in a couple of calculations though.

Am I understanding correctly that the weather data are being moved out of attributes? That would make sense, if the goal is to make better use of the Recorder database. Currently all attributes are stored in a new state_attributes record any time any of them change. That includes not only the values, but the attribute field names, as well. In JSON format. Obviously that’s a lot of duplicated data for all those weather attributes. I’ve had to exclude my weather entities and just extract what I need with templates.

For me it really only screwed up my hourly forecast stuff that came from accuweather and met.no sources . My temps and local stuff is all local from my own weather station and using the Local MQTT AmbientWeather2MQTT to draw from my console . I kept seeing the warnings but did not have time to figure out till it stopped LOL

saved my day after 2024.4 :pray:

Could you please write how did you manage to make ambientweather2mqtt working?
I installed the add-on, my weather station is ws-2902A, I managed to find app and upgrade firmware, enabled custom webserver and entered settings as they are outlined in the ambientweather2mqtt documentation but getting zero data.

Sorry I just saw this
Did you get it going?

@invisible999
I don’t remember
I just followed the instructions and it worked .

Do you see the console in a MQTT explorer?



Yes, this morning it mysteriously started working…

1 Like

Hi,

can you please share your pages.jsonl for your weather forecast widget?

This is already in the original post but
I will copy and paste
For more on my personal openhasp project.
Home assistant Forums Openhasp on a Lanbon L8 and WT32-SC01 Plus
Gethub openhasp-

In original post I Added Forecast sensors from the National weather service integration.
I really like the Forecast Details they give to use for Voice announcements of weather.

A slight chance of showers and thunderstorms before 5am, 
then a slight chance of rain. Partly cloudy. Low around 76, 
with temperatures rising to around 80 overnight. North wind 0 to 5 mph.

That assumes that you find that to be an accurate source of forecast information.

I use both national weather services,
And AccuWeather

update to National weather service template for detailed_description
Only set for twice_daily forecasts. 50% Chance of rain, otherwise partly cloudy with a high of 75F.
the service is now nws.get_forecasts_extra

Action nws.get_forecasts_extra

nws.get_forecasts_extra provides extra data in a form similar to weather.get_forecasts

1 Like

I’m trying to pull the detailed_description from the NWS forecast using the new(ish) get_forecasts_extra. I’ve been tinkering for hours and keep ending up with empty sensors. This is the code I am using in configuation.yaml for the sensors (my NWS weather entity is weather.kbtm).

template:
  - trigger:
      - platform: time_pattern
        minutes: 10
    action: 
      - service: nws.get_forecasts_extra
        data:
          type: twice_daily
        target:
          entity_id: weather.kbtm
        response_variable: twice_daily
      - variables:
          nextday: "{{ twice_daily['weather.kbtm'].forecast[2] }}"
          day: "{{ twice_daily['weather.kbtm'].forecast[0] }}"
          evening: "{{ twice_daily['weather.kbtm'].forecast[1] }}"
    sensor:
      - name: "NWS Detailed Forecast 2"
        unique_id: forecast_detailed_2
        state: "{{ nextday.detailed_description }}"

      - name: "NWS Detailed Forecast 0"
        unique_id: forecast_detailed_0
        state: "{{ day.detailed_description }}"

      - name: "NWS Detailed Forecast 1"
        unique_id: forecast_detailed_1
        state: "{{ evening.detailed_description }}"

If someone could point out what I’m doing wrong, I would be very appreciative! I can see that the template sensors get created, but they just display “Unknown.” Thanks!

I’m not familiar with the new extra
Or the weather services you are using
But I know with my setups I had to see the weather services docs and look at what is being exposed in HA with developer tools to find the data I wanted .

This is what’s been working for me.

template:
  - trigger:
      - trigger: time_pattern
        minutes: "/5"
      - trigger: homeassistant
        event: start
    action:
      - action: weather.get_forecasts
        data:
          type: twice_daily
        target:
          entity_id: weather.kbtm
        response_variable: daily
      - action: nws.get_forecasts_extra
        data:
          type: twice_daily
        target:
          entity_id: weather.kbtm
        response_variable: weather_forecast
    sensor:
      - name: Daily Forecast
        unique_id: daily_forecast
        state: "{{ now().isoformat() }}"
        icon: mdi:hours-24
        attributes:
          forecast: "{{ daily['weather.kbtm'].forecast }}"
      - name: Daily Forecast Extra
        unique_id: daily_forecast_extra
        state: "{{ now().isoformat() }}"
        icon: mdi:hours-24
        attributes:
          forecast: "{{ weather_forecast['weather.kbtm'].forecast }}"

FYI: NWS integration uses indexed attributes for the forecasts. A sensor template to extract forecast index [0], will return the near-term forecast, day or night. For twice-daily forecasts, the remainder of the indexes will represent day or night forecasts in 12-hour intervals depending on datetime and/or is_daytime attributes. They alternate between day (6 AM to 6 PM) and night (6 PM to 6 AM; which will change the current day at midnight). The behavior might complicate your sensors, however I’m guessing most weather cards use the datetime attribute to determine when each index is valid; it’s doing the work for you.

The two sensors templates I’ve been using populate the entity state with time to indicate when the forecasts change. Except for 6 AM and 6 PM (local time) forecasts, the updates seldom occur at the top of the hour.

Any suggestions on how to get the first three detailed descriptions from the extra forecasts? It used to work for me many months ago and after the recent changes, I cannot get it to work. I’ve tried numerous approaches and have the same issue: I can see the data in the response from the action using Developer Tools (see below), but however I try to access and parse that data, it’s not available. I use the detailed descriptions to show forecast text on my dashboards.

I appreciate any suggestions!


Action:
action: nws.get_forecasts_extra
target:
entity_id: weather.d6637
data:
type: twice_daily

Response:
weather.d6637:
forecast:

  • datetime: “2024-12-07T10:00:00-08:00” is_daytime: true
    detailed_description: Sunny, with a high near 80. West wind 0 to 10 mph.
    short_description: Sunny
  • datetime: “2024-12-07T18:00:00-08:00” is_daytime: false
    detailed_description: Mostly clear, with a low around 50. Southwest wind 0 to 5 mph.
    short_description: Mostly Clear
  • datetime: “2024-12-08T06:00:00-08:00” is_daytime: true
    detailed_description: Mostly sunny, with a high near 71. Southwest wind 0 to 10 mph.
    short_description: Mostly Sunny

Template:
{{ state_attr(‘weather.d6637’, ‘forecast’)[‘detailed_description’] }}

Result:
‘None’ has no attribute ‘detailed_description’

Result type: string

This template listens for the following state changed events:

  • Entity: weather.d6637

Please format your configuration properly.

You need to assign an ID for the response variable so you can extract the desired data.

action: nws.get_forecasts_extra
data:
  type: twice_daily
target:
  entity_id: weather.d6637
response_variable: value

To retrieve the first 3 detailed descriptions you would use:

{{ value["weather.d6637"]["forecast"][:3]
| map(attribute='detailed_description') | list }}

Keep in mind that the State of an entity is limited to 255 characters, so 3 days worth of detailed description is highly likely to run over that limit, which will cause the sensor to return unknown. An attribute can hold all 3 values without issue.

Thanks for the quick response and suggestion.

The action works as mine did previously in Developer Tools and provides the response required.

In Developer Tools Template, I get: UndefinedError: ‘value’ is undefined

When I create a Helper Template sensor, data is unavailable.

Am I configuring this incorrectly using your suggestion? Appreciate the help!