TTS action not executed

I am using an alarm automation successfully but have problems with the TTS action:

action:
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.schlafzimmer
      volume_level: 0.1
  - service: tts.google_say
    entity_id: media_player.schlafzimmer
    data_template:
      message: "Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}"
      cache: false
  - service: media_player.play_media
    data_template:
      entity_id: media_player.wohnung
      media_content_id: 'http://fluxfm.hoerradar.de/fluxfmberlin-live-aac-mq?sABC=59s45n23%230%23no8617362n29q2o435p17n54928n16s5%23gharva&amsparams=playerid:tunein;skey:1509186083'
      media_content_type: 'audio/mp4' 

The problem is the action with tts because it doesn’t get executed (at least I cannot hear a word and also nothing in the error log). I have tried the same action in the service tool of Home Assistant and it worked. How can I fix it in this project as well?

1 Like

the data: line needs to be data_template: if you are templating :slight_smile:

I have it already changed as above because I also thought that would solve the problem but with the updated code I cannot hear a difference (I have restarted Home Assistant).

you tried audio/mp3?

No, because it worked with tts.google_play as a json test command.
Where/how should I use audio/mp3?

instead of audio/mp4

But the first and the third service work as they should, why should I change something there to fix the second (TTS) service?

Perhaps because the second service doesn’t like mp4 when sent from HA? It is after all a video file with embedded audio as opposed to an audio file.

I fixed that but doesn’t make a difference.

Looking at the code again I think the MP3/4 won’t make a difference, I would remove the template to simplify the code and try just sending “Good Morning”, since it’s probably the templating that’s not working.

try remove Uhr, I know it will not sound perfect German, but might work

Even reducing the action to “Guten Morgen” doesn’t help. There seems to be another problem with the code!?
How can I find out about it?

I remember some user having problems with tts and ssl or something (and he got it solved, on this forum, can’t remember the link)

I have noticed that sometimes google home get into a funny state where it’s marked as a source not a sink and will not then accept any input from HA, you can usually tell when it’s in this state by looking at it’s media card.

I wish the integration would be better

I had this issue with TTS and SSL. The solution is to add the base URL to the http listing in the config yaml and suddenly sound came out.

I have added base_url: https://myaccount.dyndns.com and now I can hear a short notification sound twice in a row but still no TTS output.
Is the
message: "Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}"
not valid?

I did that. It works, but not always

Hi,

I had the same requirement, and the same problems - up to the point where I thought that templating does not work with services and / or google say. Through trial and error, I got the following configuration to work.

- action:
  - data_template:
      message: The temperature is {{ states.sensor.temperatur.state }} degrees
      entity_id: media_player.kuche
      cache: false
    service: tts.google_say

I don’t know exactly what did the trick, but comparing our two configurations, here are my suggestions. Maybe you could try them one by one, and give feedback if one worked out, and which? Ordered from most promising to least.

  1. Put the entity_id inside the data_template
  2. Message always as the first item of the data_template, even though that doesn’t seem to matter any more
  3. Message without quotes

What made the debugging a real nightmare for me was that the integrated script editor doesn’t support data_template, and that scripts updated in /config/ via SMB don’t seem to update immediately. Therefore, frequent restarts were necessary.

Hope this helps

2 Likes

Thanks a lot, now it works as it should with this code:

action:
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.schlafzimmer
      volume_level: 0.1
  - service: tts.google_say
    data_template:
      entity_id: media_player.schlafzimmer
      message: Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}
      cache: false
  - service: media_player.play_media
    data_template:
      entity_id: media_player.wohnung
      media_content_id: 'http://fluxfm.hoerradar.de/fluxfmberlin-live-aac-mq?sABC=59s45n23%230%23no8617362n29q2o435p17n54928n16s5%23gharva&amsparams=playerid:tunein;skey:1509186083'
      media_content_type: 'audio/mp3'

Only problem: https://github.com/home-assistant/home-assistant/issues/11117

1 Like