Accuweather - how to get forecast text?

Leaving aside the TERRIBLE way we have to now use weather objects, I’ve made the switch from NWS to Accuweather. There’s a way in NWS to get a twice a day forecast that contains a textual description of what it’s like or going to be like outside. This proves more useful on wall displays that have other components.

Is there way to get this out of Accuweather?

NWS:


All this text can be retrieved with the detailed_description attribute.
Accuweather:

How do you get this text??

I am using NWS and it is unfortunate that the detailedForecast was removed. It would be great to have it return in some fashion. I am experimenting with a configuration.yaml for a rest sensor that will get the NWS forecast. I can then have home assistant get the values for period.name and period.detailedForecast then speak them to my audio devices for my morning report.

sensor gov weather:
  - platform: rest
    name: Weather dot gov
    scan_interval: 3600
    # every 1 hours
    json_attributes:
      - periods
    resource: https://api.weather.gov/gridpoints/DTX/66,44/forecast
    json_attributes_path: "$.properties"
    value_template: "{{ value_json['properties']['updated']}}"

The state attributes would look something like this in HA.

periods:
  - number: 1
    name: Tonight
    startTime: "2024-04-22T18:00:00-04:00"
    endTime: "2024-04-23T06:00:00-04:00"
    isDaytime: false
    temperature: 50
    temperatureUnit: F
    temperatureTrend: rising
    probabilityOfPrecipitation:
      unitCode: wmoUnit:percent
      value: 30
    dewpoint:
      unitCode: wmoUnit:degC
      value: 1.6666666666666667
    relativeHumidity:
      unitCode: wmoUnit:percent
      value: 53
    windSpeed: 9 to 14 mph
    windDirection: SSW
    icon: https://api.weather.gov/icons/land/night/bkn/rain_showers,30?size=medium
    shortForecast: Mostly Cloudy then Chance Rain Showers
    detailedForecast: >-
      A chance of rain showers after 4am. Mostly cloudy. Low around 50, with
      temperatures rising to around 52 overnight. South southwest wind 9 to 14
      mph, with gusts as high as 24 mph. Chance of precipitation is 30%. New
      rainfall amounts less than a tenth of an inch possible.
  - number: 2
    name: Tuesday
    startTime: "2024-04-23T06:00:00-04:00"
    endTime: "2024-04-23T18:00:00-04:00"
    isDaytime: true
    temperature: 64
    temperatureUnit: F
    temperatureTrend: falling
    probabilityOfPrecipitation:
      unitCode: wmoUnit:percent
      value: 60
    dewpoint:
      unitCode: wmoUnit:degC
      value: 7.222222222222222
    relativeHumidity:
      unitCode: wmoUnit:percent
      value: 57
    windSpeed: 15 to 20 mph
    windDirection: SW
    icon: https://api.weather.gov/icons/land/day/rain_showers,50/tsra,60?size=medium
    shortForecast: Showers And Thunderstorms Likely
    detailedForecast: >-
      A chance of rain showers before 5pm, then showers and thunderstorms
      likely. Cloudy. High near 64, with temperatures falling to around 61 in
      the afternoon. Southwest wind 15 to 20 mph, with gusts as high as 31 mph.
      Chance of precipitation is 60%. New rainfall amounts between a tenth and
      quarter of an inch possible.

I like the detailed nature off the NWS forecasts. I finally got the info out of NWS using the new methods. Unfortunately to use daily forecasts I had to use AccuWeather as NWS doesn’t support it, and even then I only get 5 days.

Here’s my final sensor configs

- trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: weather.keul_daynight
    - platform: event
      event_type: event_template_reloaded
  action:
    - service: weather.get_forecasts
      data:
        type: twice_daily
      target:
        entity_id: weather.keul_daynight
      response_variable: x
  sensor:
    - name: KEUL Detailed Description 
      unique_id: keul_detailed_description 
      state: "{{ x['weather.keul_daynight'].forecast[0].detailed_description }}"
    - name: KEUL condition
      unique_id: keul_condition
      state: "{{ x['weather.keul_daynight'].forecast[0].condition }}"
    - name: KEUL is_daytime
      unique_id: keul_is_daytime
      state: "{{ x['weather.keul_daynight'].forecast[0].is_daytime }}"
    - name: KEUL last update time
      unique_id: keul_last_update_time
      state: "{{ now() }}"      
- trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: weather.wilder_id
    - platform: event
      event_type: event_template_reloaded
  action:      
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.wilder_id
      response_variable: daily
  sensor:
    - name: Weather Forecast Daily
      unique_id: weather_forecast_daily
      state: "{{ states('weather.daily') }}"
      attributes:
        temperature: "{{ state_attr('weather.wilder_id', 'temperature') }}"
        temperature_unit: "{{ state_attr('weather.wilder_id', 'temperature_unit') }}"
        forecast: "{{ daily['weather.wilder_id'].forecast }}" 
1 Like

Thanks. This is all good information. It’s helping me learn how to get information off the NWS API.

Question: How can I pull the name field off the NWS api, similar to condition or temperature ? I’m wanting name so that I can display, for example, ‘Tonight’ or ‘Tuesday Night’ in a twice a day forecast. I see name listed in the api, but nothing is getting pulled.

You can pull anything out that ends in a colon(:slight_smile:

Pull the date/time out like this

{{ (states('sensor.keul_last_update_time')|as_datetime).strftime('%A %I:%M%p')}} {{ '\n' }}{{states('sensor.keul_detailed_description') }}

And it gives this:

Monday 01:35PM
Partly cloudy, with a low around 42. Northwest wind 5 to 9 mph.

Keep in mind the NWS integration is BROKEN. It doesn’t update correctly twice a day. There’s an existing PR already open.

Jeff,
Thanks for the quick response. In your NWS “Detailed Forecast” card (above), how are you able to get to get the column entries “Tonight”, “Wednesday “, Wednesday Night”, etc ?

name: in the API has these, but I’m not able get this field to populate in my sensor attributes. Could it be called something else? I am able to get the detailed_description.

If this isn’t clear, I can post my sensor code later when I get home.

Maybe it’s because of the integration issue you mentioned.