Hello!
I have an automation that will run when Alarmo triggers. It contains a script, because I wanted to build out that part of the sequence separately for easier adding/subtracting of other actions at a later date. The issue I’m having is that I want everything to stop and reset if we disarm the alarm while it’s running. But I can’t get that to work. Here’s my automation and script:
description: >-
If the alarm is triggered the Sonos siren routine runs. If the alarm is
disarmed or 3 minutes pass, it stops the routine.
triggers:
- trigger: state
entity_id:
- alarm_control_panel.home_alarm
to: triggered
conditions: []
actions:
- action: script.home_alarm_triggered
metadata: {}
data: {}
- wait_for_trigger:
- trigger: state
entity_id:
- alarm_control_panel.home_alarm
to: disarmed
timeout:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
- action: script.turn_off
metadata: {}
data: {}
target:
entity_id: script.home_alarm_triggered
- action: media_player.media_stop
metadata: {}
data: {}
target:
entity_id: media_player.foyer
- action: media_player.volume_set
metadata: {}
data:
volume_level: 0.1
target:
entity_id: media_player.downstairs_sonos
mode: single
sequence:
- action: media_player.volume_set
metadata: {}
data:
volume_level: 0.55
enabled: true
target:
entity_id: media_player.downstairs_sonos
- data:
cache: false
entity_id: media_player.downstairs_sonos
message: >-
#Insert 12-second long message here
action: tts.cloud_say
- delay:
hours: 0
minutes: 0
seconds: 12
milliseconds: 0
- action: media_player.volume_set
metadata: {}
data:
volume_level: 0.75
enabled: true
target:
entity_id: media_player.downstairs_sonos
- action: media_player.join
metadata: {}
data:
group_members:
- media_player.family_room
- media_player.kitchen_sonos
- media_player.lr_dr
target:
entity_id:
- media_player.foyer
enabled: true
- target:
entity_id: media_player.foyer
data:
media_content_id: media-source://media_source/local/burglar_alarm_3_minutes.mp3
media_content_type: audio/mpeg
metadata:
title: burglar_alarm_3_minutes.mp3
thumbnail: null
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://media_source
action: media_player.play_media
alias: Home Alarm Triggered Sonos Routine (Duplicate)
mode: single
icon: mdi:police-badge
description: ""
Now, if I manually trigger the “script.turn_off” step of the automation while the Sonos announcement is speaking, no further steps are carried out once it finishes. But if I disarm the alarm while it is speaking, the MP3 still plays afterwards. If I disarm after the Sonos announcement finishes but while the siren MP3 is playing, it stops as expected.
To test further, I also added simple light.turn_on and light.turn_off actions, and those behaved the same way - if the alarm disarm trigger happened while Sonos was speaking, the script continued anyway. But if I disabled the Sonos parts, the light turned off when the alarm was disarmed. So I think it’s something with the script and/or the TTS aspect of it all.
Any ideas? I’m no pro, but I can futz my way around YAML with some help. I built the automation and script with the visual editor, in case that’s relevant. I appreciate any help the community can provide. Thanks!
3 posts - 2 participants