Multiple alarms playing different media at the same time

Hello folks! I’m very new to HA, but loving it so far.

However, I do have an issue. I’m attempting to set up alarms for the kids. essentially, at 3:30, I want two separate playlists to start on two separate speakers. When the morning hits though, it seemingly picks one of the automations to start at random.

Is there some limitation on timed automations starting at the same time? Or 2 instances of media_player.play_media starting at the same time? (there is also a lighting component to the setup that works in both rooms just fine), so I think it’s just the audio stuff not working. media_player.play_media is using 2 different playlists from plex. If I trigger the automations manually from the UI they work fine, it’s just the time.

Any ideas?

Both automations are a duplicate of below, with just the playlist and devices changed.

There is also a “delay” component. I presume these automations are non blocking, and are able to run simultaneously.

alias: child1-alarm
description: ""
triggers:
  - trigger: time
    at: "06:30:00"
conditions:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    after: "06:00:00"
    before: "07:00:00"
actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.1
    target:
      entity_id: media_player.child1_bedroom_wifi_speaker
  - action: media_player.play_media
    data:
      media_content_id: "plex://{ \"playlist_name\": \"child1-playlist\", \"shuffle\": \"1\" }"
      media_content_type: playlist
    target:
      entity_id: media_player.child1_bedroom_wifi_speaker
  - delay:
      minutes: 3
  - action: media_player.volume_set
    data:
      volume_level: 0.2
    target:
      entity_id: media_player.child1_bedroom_wifi_speaker
  - action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 15
      transition: 30
    target:
      entity_id: light.child1_bedroom_pendant
  - delay:
      minutes: 3
  - action: media_player.volume_set
    data:
      volume_level: 0.3
    target:
      entity_id: media_player.child1_bedroom_wifi_speaker
  - action: light.turn_on
    metadata: {}
    data:
      transition: 30
      brightness_pct: 30
    target:
      entity_id: light.child1_bedroom_pendant
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - action: media_player.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: media_player.child1_bedroom_wifi_speaker
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.child1_bedroom_pendant
mode: single

Why two automations if the trigger and condition is the same for both?

Just duplicate your actions. One set of actions for one media player and light, then one set of actions for the other media player& light. The difference in execution time will be imperceptible.

Also please use the pre-formatted text button </> for formatting your pasted config, not the quote button. Or do this: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

1 Like

No idea how your plex is set up, but can it play two streams simultaneously??

Seems to be able to. If I start a separate stream manually I can see 2 streams in the dashboard both playing

So, I took your advice, and moved it all into one automation.

alias: alarm
description: ""
triggers:
  - trigger: time
    at: "06:30:00"
conditions:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    after: "06:00:00"
    before: "14:00:00"
actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.2
    target:
      entity_id:
        - media_player.child2_bedroom_wifi_speaker
        - media_player.child1_bedroom_speaker
  - parallel:
      - action: mass.play_media
        target:
          entity_id:
            - media_player.child1_bedroom_speaker_mass
        data:
          media_id: child1-playlist
          media_type: playlist
      - action: mass.play_media
        target:
          entity_id:
            - media_player.child2_bedroom_wifi_mass
        data:
          media_id: child2-playlist
          media_type: playlist
  - delay:
      minutes: 3
  - action: light.turn_on
    metadata: {}
    data:
      transition: 300
      brightness_pct: 70
    target:
      entity_id:
        - light.child1_bedroom_pendant
        - light.child2_bedroom_pendant
mode: single

However, the same is still happening. The automation runs, the volumes are set, no music is played, and then 3 minutes later the lights turn on.

This is the timeline:

Triggered by the time at 25 November 2024 at 06:30:00

Test If the time is after 6:00 and before 14:00 and the day is Monday, Tuesday, Wednesday, Thursday or Friday

Media Player ‘Set volume’ on child2-bedroom-wifi-speaker and child1-bedroom-speaker

Execute in parallel

Perform action ‘Music Assistant: Play Media (advanced)’ on media_player.child1_bedroom_speaker

Perform action ‘Music Assistant: Play Media (advanced)’ on media_player.child2_bedroom_wifi

3 minutes later

(light.child2_bedroom_pendant) turned on

1 second later

(light.child1_bedroom_pendant) turned on

Cancelled at 25 November 2024 at 06:44:37 (runtime: 876.80 seconds)

And this is the Related Log Entries:

alarm triggered by time

06:30:00 - 3 hours ago

child2-pendant turned on triggered by automation alarm triggered by time

06:33:00 - 3 hours ago

child1-pendant turned on triggered by automation alarm triggered by time

06:33:01 - 3 hours ago

Nothing else happens :frowning: