I have several individual automations that are triggered e.g. at 4PM to play a notification, i.e. it can happen that several notifications are played on a media player at the same time.
But this causes problems because it leads to e.g. two different notifications being played at the same time.
My wish would be that in such a case the notifications are played in sequence one by one.
As an example I share two automations and a script, I use Sonos speakers and media_player.play_media
Automation 1 (trigger at 4PM over time pattern):
alias: Benachrichtigung Luftbefeuchter
description: ""
trigger:
- platform: time_pattern
minutes: /30
id: Ausgabe der Benachrichtigung
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.wassertank_luftbefeuchter_senor
state: "on"
enabled: true
- condition: state
entity_id: group.jemand_ist_zuhause
state: home
action:
- condition: time
after: "16:00:00"
before: "19:00:00"
- repeat:
sequence:
- parallel:
- if:
- condition: state
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
entity_id: binary_sensor.everything_presence_one_d5345c_occupancy
then:
- service: script.skript_benachrichtigung_wassertank_leer_wohnzimmer
metadata: {}
data: {}
enabled: true
- if:
- condition: not
conditions:
- condition: state
entity_id: light.badezimmer_licht
state: "off"
for:
hours: 0
minutes: 0
seconds: 0
then:
- service: script.skript_benachrichtigung_wassertank_leer_badezimmer
metadata: {}
data: {}
- if:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.ep_light_occupancy
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
- condition: state
entity_id: group.jemand_ist_im_bett
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
then:
- service: script.skript_benachrichtigung_wassertank_leer_schlafzimmer
metadata: {}
data: {}
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
until:
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr('fan.luftbefeuchter', 'water_tank_detached') }}"
- condition: template
value_template: "{{ not state_attr('fan.luftbefeuchter', 'no_water') }}"
mode: restart
Automation 2 (trigger at 4PM):
alias: Benachrichtigung Blumen gießen
description: ""
trigger:
- platform: time
at: "16:00:00"
id: Orchidee gießen
- device_id: f77497f31d0501cc8097ef052e6efd29
domain: zha
platform: device
type: remote_button_long_press
subtype: remote_button_long_press
id: Bestätigen
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- Orchidee gießen
- condition: time
weekday:
- mon
sequence:
- repeat:
sequence:
- parallel:
- if:
- condition: state
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
entity_id: >-
binary_sensor.everything_presence_one_d5345c_occupancy
then:
- service: script.skript_benachrichtigung_orchidee_wohnzimmer_2
metadata: {}
data: {}
enabled: true
- if:
- condition: not
conditions:
- condition: state
entity_id: light.badezimmer_licht
state: "off"
for:
hours: 0
minutes: 0
seconds: 0
then:
- service: script.skript_benachrichtigung_orchidee_badezimmer
metadata: {}
data: {}
- if:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.ep_light_occupancy
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
- condition: state
entity_id: group.jemand_ist_im_bett
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
then:
- service: script.skript_benachrichtigung_orchidee_schlafzimmer
metadata: {}
data: {}
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
until:
- condition: trigger
id:
- Bestätigen
- conditions:
- condition: trigger
id:
- Bestätigen
sequence:
- parallel:
- if:
- condition: state
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
entity_id: binary_sensor.everything_presence_one_d5345c_occupancy
then:
- service: script.alexa_benachrichtigung_restore_lautstarke
data_template:
alexa_device: media_player.sascha_s_sonos_beam
sonos_device: media_player.soundbar
alexa_service: notify.alexa_media_sascha_s_sonos_beam
alexa_volume_speak: 0.4
alexa_message: >-
<audio
src="soundbank://soundlibrary/alarms/beeps_and_bloops/bell_02"/>Vielen
Dank!"
enabled: true
- if:
- condition: not
conditions:
- condition: state
entity_id: light.badezimmer_licht
state: "off"
for:
hours: 0
minutes: 0
seconds: 0
then:
- service: script.alexa_benachrichtigung_restore_lautstarke
data_template:
alexa_device: media_player.echo_dot_badezimmer
alexa_service: notify.alexa_media_echo_dot_badezimmer
sonos_device: media_player.soundbar
alexa_volume_speak: 0.4
alexa_message: >-
<audio
src="soundbank://soundlibrary/alarms/beeps_and_bloops/bell_02"/>Vielen
Dank!"
- if:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.ep_light_occupancy
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
- condition: state
entity_id: group.jemand_ist_im_bett
state: "on"
for:
hours: 0
minutes: 0
seconds: 10
then:
- service: script.alexa_benachrichtigung_restore_lautstarke
data_template:
alexa_device: media_player.saschas_echo_dot
alexa_service: notify.alexa_media_saschas_echo_dot
sonos_device: media_player.soundbar
alexa_volume_speak: 0.4
alexa_message: >-
<audio
src="soundbank://soundlibrary/alarms/beeps_and_bloops/bell_02"/>Vielen
Dank!"
mode: restart
And here a script:
alias: Skript Benachrichtigung Orchidee Schlafzimmer
sequence:
- service: media_player.play_media
data:
media_content_id: >-
media-source://media_source/local/528475__robinhood76__09156-accent-chime-login.wav
media_content_type: audio/mpeg
announce: true
extra:
volume: 25
target:
device_id:
- c837fe7ce89808b6c675572ebea8e9cb
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: media_player.play_media
data:
media_content_id: >-
media-source://tts/cloud?message=%E5%85%B0%E8%8A%B1%E5%A4%AA%E5%B9%B2%E9%9C%80%E8%A6%81%E6%B5%87%E6%B0%B4%E3%80%82&language=zh-HK&voice=WanLungNeural
media_content_type: music
announce: true
extra:
volume: 25
target:
device_id:
- c837fe7ce89808b6c675572ebea8e9cb
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: media_player.play_media
data:
media_content_id: >-
media-source://tts/cloud?message=Die+Orchidee+ist+zu+trocken%2C+bitte+gie%C3%9Fen.&language=de-DE&voice=KatjaNeural
media_content_type: music
announce: true
extra:
volume: 25
target:
device_id:
- c837fe7ce89808b6c675572ebea8e9cb
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: media_player.play_media
data:
media_content_id: >-
media-source://media_source/local/528475__robinhood76__09156-accent-chime-login.wav
media_content_type: audio/mpeg
announce: true
extra:
volume: 25
target:
device_id:
- c837fe7ce89808b6c675572ebea8e9cb
mode: single
icon: mdi:account-voice
Maybe someone has a solution how the notifications can be played in sequence in case two notifications are triggered at the same time from different automations.
Many thanks