Turn off alarm sound when alarm disarmed

I’m using the Alexa Media Player custom integration to make a home alarm system. I have two automations, one for notification when alarm is triggered (with sound) and one for turning off the sound if alarm is disarmed. The first is working, but the second never kicks in.

Notification:

alias: Send notification when home alarm is triggered
trigger:
  - platform: state
    entity_id: alarm_control_panel.home_alarm
    to: triggered
action:
  - service: notify.pushover
    data:
      message: Alarm, husalarmen er utløst!
  - repeat:
      count: '3'
      sequence:
        - service: notify.alexa_media
          data:
            message: >-
              <audio
              src="soundbank://soundlibrary/scifi/amzn_sfx_scifi_alarm_04"/>
            target: media_player.yngve_s_echo
            data:
              type: tts
mode: single

Turn off alarm sound if alarm is disabled:

alias: 'Alarm: Slå av alarmlyd'
description: ''
trigger:
  - platform: state
    entity_id: alarm_control_panel.home_alarm
    from: armed_away
    to: disarmed
condition: []
action:
  - service: media_player.turn_off
    target:
      entity_id: media_player.yngve_s_echo
mode: single

I’ve also tried - service: media_player.volume_mute
Anyone got some thoughts?

I no expert but try deleting

from: armed_away

Thanks for reaching out, but unfortunately it did not work

Try:

from: triggered

(no to: state)

You could also use an until or while loop instead of repeat in the media player loop. Loop until the loop index is 3 or the alarm state is not triggered.

Thanks!

from: triggered

that I understand, but can you explain what you mean by: “(no to: state)”? Is it like “nothing” in the “To-state”, because that didn’t work:

from: triggered
to:

Of course it’s going to be:

from: triggered
to: disarmed

thanks a lot @tom_l !!

No to: state at all. Just leave it out.

The way you have it now the alarm won’t stop if the state changes back to armed_away.

1 Like