Unable to get detailed_description from NWS Weather Forcast

I’m using the detailed_description data from the National Weather Forcast to create a spoken daily update of the day’s news and weather. With the recent update to HA the data does not seem to be available any longer.

I’ve reverted back to the previous release and will not be upgrading unless there’s a work around or resolution.

An example of the data:

- detailed_description: Mostly cloudy, with a high near 50. North wind 10 to 15 mph.
  datetime: '2024-04-04T08:00:00-05:00'
  precipitation_probability: 0
  is_daytime: true
  condition: cloudy
  wind_bearing: 0
  temperature: 50
  dew_point: 31
  wind_speed: 12.5
  humidity: 72

Please see the NWS change in the Backward-incompatible changes in the 2024.4 Release Notes.

Yes I’m aware - but the detailed_description is not being pulled as far as I can see.

Looks like there may be a related issue on GitHub

I’m seeing the same behavior - the detailed_descriptions are no longer being populated. Validated this on my test Home Assistant install - 2024.3 works correctly; 2024.4 does not.

I’ve been informed by developers that since the weather.get_forcast service call has been deprecated the National Weather Service integration will not be providing the STATES information any longer. Instead we’ll have to do service calls for weather:get_forcasts to get the information. Meaning that we’ll have to do some creative scripting to first get the information then extract it for our needs.

I’m fairly new to Home Assistant, so apologies if I’m restating something that’s already been said in this thread. I’ve been trying to get this to work as well. I have a template sensor that uses get_forecasts, and it works properly:

- trigger:
  - platform: time_pattern
    hours: /1
    - service: weather.get_forecasts
        type: twice_daily
        entity_id: weather.khio
      response_variable: daily
    - name: Daily Forecast
      unique_id: daily_forecast
      state: "{{ now().isoformat() }}"
      icon: mdi:hours-24
        forecast: "{{ daily['weather.khio'].forecast }}"

And here’s what the sensor data looks like:

The issue is how to get the detailed_description back out. I don’t yet know enough to do the “creative scripting”. Has anyone gotten a working solution for this?

FYI - I was continuing to research this, and came across a similar post for different data that provided the solution. Here’s what I’m using:

{% set forecast = state_attr('sensor.daily_forecast','forecast') %}
{{ forecast[0].detailed_description }}

Now I can get the forecast in my morning voice briefing. :partying_face:

This works for me:

- trigger:
    - platform: time_pattern
      minutes: 10
    - service: weather.get_forecasts
        type: twice_daily
        entity_id: weather.kmsp_daynight
      response_variable: daily
    - name: "Day Forecast 1"
      unique_id: "day_forecast_1"
      state: "{{ daily['weather.kmsp_daynight'].forecast[0].detailed_description }}"

    - name: "Day Forecast 2"
      unique_id: "day_forecast_2"
      state: "{{ daily['weather.kmsp_daynight'].forecast[1].detailed_description }}"

    - name: "Day Forecast 3"
      unique_id: "day_forecast_3"
      state: "{{ daily['weather.kmsp_daynight'].forecast[2].detailed_description }}"

    - name: "Day Forecast 4"
      unique_id: "day_forecast_4"
      state: "{{ daily['weather.kmsp_daynight'].forecast[3].detailed_description }}"

Replace the weather.kmsp_daynight service with your weather service sensor.
I have a separate templates.yaml folder, this goes at the top.

1 Like

Home Assistant Community Post

Title: Issues Storing Weather Forecast Data with New get_forecasts Service

Hello All,

I’m having trouble utilizing the new weather.get_forecasts service with the NWS integration. Historically, I used the old method where the weather entity had an attribute called forecast, which allowed me to drive my automations using weather data. Even though this method was deprecated, I can still see hourly and twice daily data in the UI when I click on the entity.

I understand that the new recommended approach is to use the get_forecasts service. I can successfully retrieve data using this service in the developer console, but I’m struggling to store this data in a way that can be parsed and used in automations.

Here are the steps I’ve tried:

  1. Using input_text Entities:

    • I attempted to write the forecast data to input_text entities.
    • However, this exceeds the 256 character limit, resulting in errors and the state falling back to unknown.
  2. Shell Command to Store Data in a File:

    • I considered using a shell command to write the forecast data to a file and then read it back into Home Assistant.
    • This approach seemed overly complex for what should be a straightforward task.

What am I missing here? How can I write the forecast data returned by the get_forecasts service to an entity in Home Assistant so that I can parse and use it in my automations?

Alternatively, since I can see the data in the NWS entity, how do I now access this?

Thank you for your help!

Did you get the answer you needed? If not this is a solution that has worked for me.

- trigger:
    - platform: time_pattern
      # Get most recent forecast at 5 minutes after the hour
      minutes: 5
    - service: weather.get_forecasts
        type: twice_daily
        entity_id: weather.kmsp_daynight
      response_variable: daily_forecast

    - name: "Daily Forecasts"
      unique_id: "daily_forecasts"
      state: "{{ now() }}"
        forecast_0: "{{ daily_forecast['weather.kmsp_daynight'].forecast[0].detailed_description }}"
        forecast_1: "{{ daily_forecast['weather.kmsp_daynight'].forecast[1].detailed_description }}"
        forecast_2: "{{ daily_forecast['weather.kmsp_daynight'].forecast[2].detailed_description }}"
        forecast_3: "{{ daily_forecast['weather.kmsp_daynight'].forecast[3].detailed_description }}"

This creates a new sensor called Daily Forecasts. The actual sensor data is the date/time of the forecast and each of the attributes contain the textual data. You can then get the data with a state_attr(‘sensor.daily_forecast’,‘forecast_0’), etc

Substitute the kmsp_daynight portion for the weather station you need.

This new sensor is at the top of my templates.yaml file and before all other sensors defined in the file, the sensor section is combined with all the other sensors.

Be aware — the NWS forecast has been erratic lately, and if it stops working all the sensors in the template.yaml will also stop working. Don’t know a work around at this point.