Using templates in Google Home push TTS

I’m trying to get a custom “good morning” routine going. The first thing I’m working on is a Google travel time sensor. I have that up and working, but I can’t use it in a template for TTS. It works as expected when testing the same message over the Notify component to my Pushbullet.

Google Home is speaking the template instead of the template value that should result from the template.

Example: Using the Services page to manually trigger this event

Domain: tts
Service: google_say
Service Data:
{
  "cache": false,
  "entity_id": "media_player.bedroom_home",
  "message":  "If you left now, it would take {{ states('sensor.travel_time') }} minutes to get to Work Location."
}

The {{ states('sensor.travel_time) }} template results in the number 18 (for 18 minutes). Instead of saying “eighteen” the Google home will say: “It will take states sensor dot travel underscore minutes to get to Work Location.”

However, as I said, when sending the same message over the Notify domain, the template gets evaluated to the number 18 as expected.

Am I missing anything here, or is this a limitation/bug with TTS right now?

1 Like

Use data_template and your sensor should look like this

{{ states.sensor.travel_time.state ))

Here’s an example from a test script I run:

sequence:
- service: tts.google_say
  entity_id: media_player.living_room_home
  data_template:
    message: 'Hello, Robert. The temperature outside is currently {{ states.sensor.dark_sky_temperature.state }} degrees.'
    cache: false
2 Likes

Good idea, are you trying to replace the daily briefing with your own routine? I like it! I’m going to give this a try as well.

Yes, I am. The daily briefing isn’t very useful, especially since it’s mostly designed for a single user. I want something that can trigger a few times automatically while my wife and I are getting ready in the morning to let us know how much we need to rush out the door to get to work on time. That, along with weather summary and any other information I can jam in there.

Currently trying out solution suggested by @rpitera

Nice! I currently just have an automation to start NPR in the morning, but getting the daily briefing stuff in there would be great too. Especially, like you said, it wouldn’t have to be just for me, could be for my wife’s commute too.

Have you played with the Google Calendar component yet? That would be a good one too, I would think to add.

That solution worked beautifully.

I don’t have an issue with using it within a script, but is there any reason why it can’t be used in the TTS service itself like I can use it in Notify?

Got this setup as part of my morning routine now as well. Thanks for the idea!

No issue, I just did that while testing. I often test service calls via script so I can manually trigger; this way I know that the action will work and if the automation fails it narrows down the problem to either conditions or triggers.

I have exactly the same problem.
google tts dont speak the actual value, only the text inside the tamplate. Whats wrong?

   action:
     service: tts.google_say
     data:
       entity_id: "media_player.vlc"
       message: 'Die Temperatur betraegt {{ states.sensor.dark_sky_temperature.state }} Grad.'
       cache: false

Change data to data_template

2 Likes

thx man,
have it totally overlooked

I had it working just fine with data_template, but not anymore…altough the telegram notification is sending the value, this is my script:
notificar:
sequence:

  • service: telegram_bot.send_message
    data_template:
    title: ‘{{ titulo }}’
    message: ‘{{ mensaje }}’
  • service: persistent_notification.create
    data_template:
    title: ‘{{ titulo }}’
    message: ‘{{ mensaje }}’
  • service: tts.google_say
    entity_id: media_player.oficina
    data_template:
    message: ‘{{ mensaje }}’
    cache: false
    Persistent and telegram says the correct value, but not TTS
    Any ideas?

I have the same isue.
my auto mation is::

 id: '1560719023217'
  alias: AVISO CONSUSMO
  trigger:
  - above: '3000'
    entity_id: sensor.general_power
    for: 00:03:00
    platform: numeric_state
  condition: []
  action:
  - data:
      message: Alerta de consumo de mas de 3000w  por 3 minutos ,   el consumo actual
        es  {{states.sensor.general_power.state}} W
    service: notify.teleg_ariel
  - data:
      message: Alerta de consumo de mas de 3000w  por 3 minutos ,   el consumo actual
        es  {{states.sensor.general_power.state}} W
    entity_id: media_player.google_home
    service: tts.google_say
    

Here you go