TTS to read state of an entity

Hi all,
Im trying to setup automation to read the today weather (sunny, rainy, etc) every morning. I got it to read “The weather for today is” then unable to read the states from the entity and would eventually like it to read the current temperature too. I assume once I got this figure out I can figure out the last part.

I’m new to HA, hope someone can point me to the right syntax.

- id: '1588920169520'
  alias: Test Weather Report
  trigger:
  - at: 08:00:00
    platform: time
  action:
  - data:
      volume_level: 0.2
    entity_id: media_player.bose_soundtouch
    service: media_player.volume_set
  - data:
      entity_id: media_player.bose_soundtouch
      message: The weather for today is {{ states(weather.test_home) }}
    service: tts.google_translate_say

1

  - data_template:
      entity_id: media_player.bose_soundtouch
      message: "The weather for today is {{ states('weather.test_home') }}"
    service: tts.google_translate_say

I tried that, and it just read out “The weather for today is states weathe test home”

No you didn’t.

Look closer.

data vs data_template.

ops… changed to data_template. Still no luck.

Post your exact config.

- id: '1588920169520'
  alias: Test Weather Report
  trigger:
  - at: 08:00:00
    platform: time
  action:
  - data:
      volume_level: 0.2
    entity_id: media_player.bose_soundtouch
    service: media_player.volume_set
  - data_template:
      entity_id: media_player.bose_soundtouch
      message: "The weather for today is {{ states('weather.test_home') }}"
    service: tts.google_translate_say

Try it like this:

  action:
  - data:
      volume_level: 0.2
    entity_id: media_player.bose_soundtouch
    service: media_player.volume_set
  - service: tts.google_translate_say
    entity_id: media_player.bose_soundtouch
    data_template:
      message: "The weather for today is {{ states('weather.test_home') }}"

Mate, you are a legend. That works ! Cheeers !

No worries. Some services are picky about where they require the entity_id to be. There seems to be no consistency on whether it is inside or outside the data_template. See:

I didn’t read the whole topic (although I’ve heard bits of this discussion about this issue before), but I think I understand that this doesn’t work (i.e., entity_id inside data_template):

  - data_template:
      entity_id: media_player.bose_soundtouch
      message: "The weather for today is {{ states('weather.test_home') }}"
    service: tts.google_translate_say

But this works (i.e., entity_id outside data_template):

  - service: tts.google_translate_say
    entity_id: media_player.bose_soundtouch
    data_template:
      message: "The weather for today is {{ states('weather.test_home') }}"

Do you think this would also work (i.e., entity_id inside data_template, but its value as a list instead of a single string):

  - data_template:
      entity_id:
      - media_player.bose_soundtouch
      message: "The weather for today is {{ states('weather.test_home') }}"
    service: tts.google_translate_say

It would be very interesting to see if it does.

Yup, that works too.