Automation problem - Executing multiple services with audio

Hi,

I have created an automation that triggers 4 actions as follow:

action:
  - service: media_player.volume_set
    data:
      entity_id: media_player.living_room_speaker
      volume_level: "1"
  - service: tts.google_translate_say
    data:
      entity_id: media_player.living_room_speaker
      language: pt
      message: Intrusos detetados, a contactar as autoridades.
  - service: media_player.play_media
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: /local/alarm_sound_1.mp3
      media_content_type: "audio/mp4"
  - service: notify.notify
    data:
      title: "ALARME"
      message: "Detectado movimento no interior quando ninguém estava em casa"

The 1st and last actions are executing just fine, but I’m not able to run the other two as well. Each time I execute the automation or it runs the TTS service or the play_media service, but never the two. I wanted them to run in a sequence executing one afther the other. Is it possible with two audio services on the same speaker? Am I missing something?

You may need to add some seconds of delay between each action:

  - delay: 00:02:00

I’ve noticed that my media player (Kodi) won’t respond to a new request unless I wait a bit after the first action before it will accept a second attempt. Try adding some 5 or 10 second delays between each, and if that works keep reducing the time until you find the sweet spot.

1 Like

Works perfectly with a 5sec delay, thanks!

Here’s the edited code, it may help someone in the futur:

action:
  - service: media_player.volume_set
    data:
      entity_id: media_player.living_room_speaker
      volume_level: "1"
  - service: tts.google_translate_say
    data:
      entity_id: media_player.living_room_speaker
      language: pt
      message: Intrusos detetados, a contactar as autoridades.
  - delay: "00:00:05"
  - service: media_player.play_media
    data:
      entity_id: media_player.living_room_speaker
      media_content_id: /local/alarm_sound_1.mp3
      media_content_type: "audio/mp4"
  - service: notify.notify
    data:
      title: "ALARME"
      message: "Detectado movimento no interior quando ninguém estava em casa"