Speak weather using TTS (text to speech)

I am trying to get a variable to be spoken by Google TTS from a wunderground sensor. I think I am getting close, however I cant figure out how to get the variables all the way from the sensor into script.

Sensor:

sensor:
  - platform:             wunderground
    api_key:              !secret wunderground
    monitored_conditions:
      - alerts
      - feelslike_f
      - weather_1d_metric
      - weather_1n_metric
      - weather_2d_metric
      - weather_2n_metric
      - weather_3d_metric
      - weather_3n_metric
      - weather_4d_metric
      - weather_4n_metric
      - temp_high_record_f
      - temp_high_1d_f
      - temp_f
      - temp_low_1d_f
      - temp_low_record_f
      - precip_1d
      - precip_1d_mm
      - wind_mph
      - wind_1d_mph

Script:

sequence:
service: tts.google_say
entity_id: media_player.whole_house
data_template:
message: The temperature currently is {{ {states(‘sensor.temp_high_record_f’) }} .’

I have my Dark Sky spoken like this…

  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.master_bedroom_home
        volume_level: 0.5
    - service: tts.google_say
      entity_id: media_player.master_bedroom_home
      data_template:
        message: >
          The weather for the next 24 hours is {{states ('sensor.dark_sky_hourly_summary') }}

I think you need to remove the { from {states

1 Like

Currently all I’m getting back is unknown… Did you have to pass that variable into the script? Or does it just appear for free?

it just speaks the value of the sensor. Did you remove the extra { ? Mine is also a direct part of an automation, not in a script.

#Weather forecast for the next 24 hours daily at 7pm

- alias: Weather Forecast
  trigger:
    platform: time
    at: '19:00:00'
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.master_bedroom_home
        volume_level: 0.5
    - service: tts.google_say
      entity_id: media_player.master_bedroom_home
      data_template:
        message: >
          The weather for the next 24 hours is {{states ('sensor.dark_sky_hourly_summary') }}
1 Like

Here is an example of how I did one of my template messages.

- service: notify.bathroom_tablet
  data_template:
    message: >
      Good morning.
      It's currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees.
      {% if is_state("sensor.allergy_season", "True")  %}
      The pollen level for today is {{states.sensor.pollen_level.state}} or {{states.sensor.pollen_index.state}} percent.
      {% endif %}
      {% if is_state("sensor.flu_season", "True") %}
      The flu risk for today is {{states.sensor.cold_flu_risk.state}} or {{states.sensor.cold_flu_percentage.state}} percent.
      {% endif %}
      Today you can expect {{states.sensor.dark_sky_hourly_summary.state}}.
      With a high of {{states.sensor.dark_sky_daily_high_temperature.state|round|int}} and a low of {{states.sensor.dark_sky_daily_low_temperature.state|round|int}}.
      {% if states.sensor.dark_sky_wind_speed.state|int > 10 %}
      Be advised it is windy outside.
      {% endif %}
      {% if states.sensor.to_lafontaine.state|int > 40 %}
      Be advised the travel time to lafontaine is over 40 mintues today.
      {% endif %}
2 Likes

Where did you get the pollen level sensor?

Yes, I removed it. Maybe I’ll try dark_sky for now and see how that rolls.

Well, I missed a small detail completely at the bottom. I should be calling this:

{{states.sensor.pws_weather_temp_high_1d_f}}

THANK YOU! You da man!!!