Wait template - Chromecast not active?

Hello. I have the following automation triggering for reminding everybody that the trash is getting picked up. What it does on triggered:

  • mute TV (so that I can hear the message)
  • speak through chromecast to another speaker
  • unmute TV.

I have different speak-messages that varies in length so the mute delay for 8 secs, is sometimes too long or too short. Is it possible to change this with a wait template that unmutes the TV when the message is done playing?

My configuration:

- alias: Trash
  trigger:
    - platform: state
      entity_id: sensor.garbage_pickup
      to: 'on'
  action:
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
         - Mute
        device: 10391392
    - service: tts.amazon_polly_say
      data_template:
        entity_id: media_player.chromecast
        message: >
          <speak>Here I say something of different lengths</speak>
    - delay: 00:00:08
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
         - Mute
        device: 10391392

How about breaking it into 2 automations?
Have the first automation mute the TV and play the message, and have the second automation trigger on the Chromecast/speaker media_player status changing to idle / off / != playing depending on how it behaves once it’s done playing?

- alias: Trash
  trigger:
    - platform: state
      entity_id: sensor.garbage_pickup
      to: 'on'
  action:
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
         - Mute
        device: 10391392
    - service: tts.amazon_polly_say
      data_template:
        entity_id: media_player.chromecast
        message: >
          <speak>Here I say something of different lengths</speak>
    - wait_template: "{{ is_state('media_player.chromecast' , 'idle') }}"
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
         - Mute
        device: 10391392
1 Like

Oh I wasn’t aware of the wait_template. I like that very much :slight_smile:

Is there a blushing-face emojii? Feel kind of stupid for asking this question now. It is, of course, as easy as you have written it. I cannot understand how I managed to over-complicate this in my head :slight_smile: Thanks a lot!

As a little sidenote, I really like this HA community!

2 Likes

Never feel stupid asking a question, you’ll learn something from the answer and so will hundreds of other people :+1:

3 Likes