NWS Weather TTS works in editor but not in configuration

I’m trying to automate a weather announcement. I’ve looked through many topics on this site regarding this, but can’t get it to work.

I have the national weather service installed and running. It is working in the preview editor

However when my google nest executes this same command, it just says “none” and nothing more. What am I doing wrong here?

This is my automation

- id: '1711667890345'
  alias: testtttttttt
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: d9ade780d1327377b520f88c82038460
    entity_id: 43375b77ce1ac480f67f881e13f5b497
    domain: binary_sensor
  condition: []
  action:
  - service: tts.google_say
    metadata: {}
    data:
      entity_id: media_player.nest_mini_office
      message: >-
        {{state_attr('weather.kalb_daynight', 'forecast')[0]['detailed_description']}}
  mode: single
message: >
        {% set forecast = state_attr('weather.kalb_daynight', 'forecast')[0] %}
        The weather forecast for today is {{ forecast.condition }}, with a temperature of {{ forecast.temperature }} degrees Celsius, and a chance of precipitation of {{ forecast.precipitation_probability }} percent.

ScreenShot_20240329162544
/
attribution: Data provided by OpenWeatherMap

This doesn’t work for me

Here’s my full automation

- id: '1711667890345'
  alias: testtttttttt
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: d9ade780d1327377b520f88c82038460
    entity_id: 43375b77ce1ac480f67f881e13f5b497
    domain: binary_sensor
  condition: []
  action:
  - service: tts.google_say
    metadata: {}
    data:
      entity_id: media_player.nest_mini_office
      message: >
        {% set forecast = state_attr(weather.kalb_daynight', 'forecast')[0] %}
        The weather forecast for today is {{ forecast.condition }}, with a temperature of {{ forecast.temperature }} degrees Celsius, and a chance of precipitation of {{ forecast.precipitation_probability }} percent.
  mode: single

If I check it in the YAML editor, it shows this error
error

You’re missing a ’ before (weather.kalb_daynight', 'forecast') on line 16.

1 Like

Wonderful thanks so much, I got it working

1 Like

One last thing, would you be able to show me how to get high/low temps for the day? I can’t seem to find which members are in the “forecast” object anywhere so I’m not sure which attribute to point to. For example forecast.temp_min and forecast.temp_max or something along those lines?

I actually don’t think those are exposed/sent on the NWS integration. I use OpenWeatherMap for that. Although, as I type that, my forecast low temp is reading as “Unknown” :rofl:

:thinking:
forecast.temperature
forecast.templow

 message: >
        {% set forecast = state_attr('weather.kalb_daynight', 'forecast')[0] %}
        The weather forecast for today is {{ forecast.condition }}, with a temperature of {{ forecast.temperature }} degrees Celsius, and a chance of precipitation of {{ forecast.precipitation_probability }} percent. The high for today will be {{ forecast.temperature }} degrees Celsius, and the low will be {{ forecast.templow }} degrees Celsius.
1 Like