Make Google TTS interpret template which is passed to script before?

I am using the sonos_say script as described in the cookbook:

sonos_say:
  alias: "Sonos TTS script"
  sequence:
   - service: sonos.snapshot
     data:
       entity_id: "{{ sonos_entity }}"
   - service: sonos.unjoin
     data:
       entity_id: "{{ sonos_entity }}"
   - service: media_player.volume_set
     data:
       entity_id: "{{ sonos_entity }}"
       volume_level: "{{ volume }}"
   - service: tts.google_translate_say
     data_template:
       entity_id: "{{ sonos_entity }}"
       message: "{{ message }}"
       language: 'de'
   - delay: "{{ delay }}"
   - service: sonos.restore
     data:
       entity_id: "{{ sonos_entity }}"

This is part of an automation in which I call the script:

    - service: script.sonos_say
      data:
        sonos_entity: media_player.unnamed_room
        volume: 0.5
        message: "Test: Read the state of {{ ((states.sensor.netatmo_home.state))  }}"
        delay: '00:00:15'

If I do this Google TTS creates an mp3 reading back “…states dot sensor dot…”. I read that to change this I have to change data to data_template when calling the google service which I do (see above), but somehow the template inside the template (because it gets passed to the service using the script) doesn’t render.

Can someone point me in the right direction for this?

I use a modified version of the script from the cookbook. my automation action section that calls the script looks like this:

    action:
      - service: script.text_to_speech
        data_template:
          speaker: "media_player.{{ states('input_select.speaker') | replace(' ','_') }}"
          volume: "{{ states('input_number.text_to_speech_volume') | float }}"
          message: "{{ states('input_text.text_to_speech') }}"

I’m guessing, but I think there’s an issue with the quotation marks " in your message and the script/template is doing a literal interpretation of them. Try adding single quotation marks ' around the sensor state template.

Thanks for the feedback! As Google TTS is pretty unstable right now I postponed further testing to 0.118 where the issues are supposed to be fixed.

I use Google TTS regularly and don’t have an issue. I don’t think there’s any stability issues with it. There were issues a few versions ago but they have been resolved.