TTS simultaneous speech to multiple Google speakers

This is a handy script for sending text-to-speech to multiple google speakers (i.e. home, or mini, or whatever else they decide to call them next). It took me longer to figure this out than I expected so I’m putting it here for anyone else.

My only “issue” is that the first time you send a text the speakers play a chime sound before saying the message. Send it again and they say the message without the chime. It’s not really a problem, but it is inconsistent. I can live with it if I try really hard.

I’m not sure when or how the chime element resets, but I’d be curious to know how to control the chime if anyone knows.

# simultaneous speech to multiple google speakers
tts_google_speakers:
  sequence:
    - action: tts.speak
      metadata: {}
      data:
        cache: true
        media_player_entity_id: "{{ media_players }}"
        message: "{{ my_message }}"
        language: en
      target:
        entity_id: tts.google_translate_en_com
  mode: single
# USAGE 
# tap_action:
#   action: perform-action
#   perform_action: script.tts_google_speakers
#   data:
#     media_players:
#       - media_player.office_speaker
#       - media_player.family_room_speaker
#       - media_player.kitchen_speaker
#       - media_player.living_room_speaker
#       - media_player.media_room_speaker
#       - media_player.studio_speaker
#     my_message: This is my message

The chime is played when Home Assistant starts casting to the speaker, sending another TTS while it’s still casting (speaker state is not idle) will not trigger the chime again.

Why not create a group in Google Home that includes all Google assistants and call it a day?

Good question. At one time I tried sending to a group of speakers and it didn’t work. That might no longer be the case.

However the real reason I don’t use a group is because I use this script in various circumstances which allows me to simply uncomment whichever speakers are appropriate. Otherwise I would need to create a new group for each different set of speakers. Since this is the only place where I would address that set of speakers, not creating a group cuts out the middleman.

I just sent a TTS that lasted about 2 seconds. It’s been several minutes and the speaker remains in an idle state. I’m not sure when it will time out.

If I were dead-set on silencing the chime, I might be able to figure out the timeout then set up an automation to send silent commands before each timeout (e.g. infinitesimally altering the volume - if that indeed resets the timeout). Or perhaps there is a way to adjust the timeout directly. Just an academic exercise however. I look forward to replacing my cloud-based speakers when it becomes practical.

1 Like