Help for alarm automations

Hello, i’m new to home assistant.

I want to do an automation that will do this: when alarm activated, start the sound and put the light in such state. Then when the alarm is deactivated, return to the initial state but I can not arrive and I do not know if I should put the code in automation or in configuration.yaml?

I’m also looking for a way to snooze the sound on Alexa until the alarm is turned off.

Thank you for your help :slight_smile:

alias: Triggered
trigger:
  - platform: state
    entity_id: alarm_control_panel.alarmo
    to: triggered
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_id: xxxxxxxxxxxxxxxxxx
      media_content_type: skill
    entity_id: all
  - service: scene.create
    data:
      data:
        scene_id: before
        snapshot_entities:
          - light.romm1
          - light.room2
          
  - service: light.turn_on
    data:
      effect: Police
      entity_id: light.room1
  - service: light.turn_on
    data:
      brightness: 255
    entity_id: light.room2
    
alias: Disarmed
trigger:
  - platform: state
    entity_id: alarm_control_panel.alarmo
    to: disarmed
condition: []
action:
  - service: scene.turn_on
    data:
      entity_id: scene.before

I took example on this : https://www.home-assistant.io/integrations/scene/

I also take any advice

You can copy the automation yaml like this.

On first look, I cant find any issues with this. But just to confirm Do you want to trigger a skill when the alarm is trigerred?

1 Like

I have only this on automation :

alias: Alarm triggered
trigger:
  - platform: device
    device_id: 78ad9737eee9945668214c18e1666f4f
    domain: alarm_control_panel
    entity_id: alarm_control_panel.alarmo
    type: triggered
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_id: xxxxxxxxxxxxxxx
      media_content_type: skill
    entity_id: all
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities:
        - light.room1
        - light.room2
  - service: light.turn_on
    data:
      entity_id: light.room1
      effect: Police
  - service: light.turn_on
    data:
      entity_id: light.room2
      brightness: 255
      
mode: single

The rest can’t be saved. I don’t know why.
Yes it’s a skill when the alarm is trigerred. (for media player skill it’s the sound of alarm because i have soundbar but media.player basic don’t work so i through via alexa.)

You have to copy this as a new automation and ot copy both together. Did you do like that?

1 Like

Aaaaah ok lol so i can’t copy both together. Thank you :grinning:

I tested and everything works but when I turn the lamp back on, it stays in the ‘Police’ effect.
I also have the problem of repeating the skill media player (sound of alarm last 30 seconds) until the state becomes disarmed… And conversely stop the media.player when disarmed (media_player.media_stop don’t work).

Are both the lamps having this issue? Try this.

alias: Alarm triggered
trigger:
  - platform: device
    device_id: 78ad9737eee9945668214c18e1666f4f
    domain: alarm_control_panel
    entity_id: alarm_control_panel.alarmo
    type: triggered
condition: []
action:
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities:
        - light.room1
        - light.room2
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: light.turn_on
    data:
      entity_id: light.room1
      effect: Police
  - service: light.turn_on
    data:
      entity_id: light.room2
      brightness: 255
  - repeat:
      until:
        - condition: state
          entity_id: alarm_control_panel.alarmo
          state: disarmed
      sequence:
        - service: media_player.play_media
          data:
            media_content_id: xxxxxxxxxxxxxxx
            media_content_type: skill
          entity_id: all
        - delay:
            hours: 0
            minutes: 0
            seconds: 32
            milliseconds: 0      
mode: single
1 Like

Thank you I added this, it works I understood the concept.
For the lamps they are not the same, room2 (ceiling) returns to the initial state but room1 (Yeelight Smart Bulb 2) if it was off goes off again but when I turn it on I still have the “Police” effect.

Isn’t there a function to stop the alarm directly as soon as it is disarmed? (maybe with a skill alexa with a mp3 empty ?)

You can try to play a sound in alexa such as a bell which should exit the skill. With the lights, i have sometimes seen this issue when I use 2 entites in snapshots. Try this. Also i have combined both the automations into one. You can disable the second one and try this.

alias: Alarm triggered
trigger:
  - platform: device
    device_id: 78ad9737eee9945668214c18e1666f4f
    domain: alarm_control_panel
    entity_id: alarm_control_panel.alarmo
    type: triggered
condition: []
action:
  - service: scene.create
    data:
      scene_id: before1
      snapshot_entities: light.room1
  - service: scene.create
    data:
      scene_id: before2
      snapshot_entities: light.room2
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: light.turn_on
    data:
      entity_id: light.room1
      effect: Police
  - service: light.turn_on
    data:
      entity_id: light.room2
      brightness: 255
  - repeat:
      until:
        - condition: state
          entity_id: alarm_control_panel.alarmo
          state: disarmed
      sequence:
        - service: media_player.play_media
          data:
            media_content_id: xxxxxxxxxxxxxxx
            media_content_type: skill
          entity_id: all
        - delay:
            hours: 0
            minutes: 0
            seconds: 32
            milliseconds: 0 
  - wait_for_trigger:
      - platform: state
        entity_id: alarm_control_panel.alarmo
        to: disarmed
  - service: scene.turn_on
    data: {}
    entity_id: 'scene.before1,scene.before2'
  - service: notify.alexa_media_everywhere
    data:
      message: Alarm disarmed
      data:
        type: announce
        method: all    
mode: single

I have no return to previous state and the alexa message is not working.
I have the impression that it not consider the wait_for_trigger.

I just checked and You actually don’t need the wait_until

alias: Alarm triggered
trigger:
  - platform: device
    device_id: 78ad9737eee9945668214c18e1666f4f
    domain: alarm_control_panel
    entity_id: alarm_control_panel.alarmo
    type: triggered
condition: []
action:
  - service: scene.create
    data:
      scene_id: before1
      snapshot_entities: light.room1
  - service: scene.create
    data:
      scene_id: before2
      snapshot_entities: light.room2
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: light.turn_on
    data:
      entity_id: light.room1
      effect: Police
  - service: light.turn_on
    data:
      entity_id: light.room2
      brightness: 255
  - repeat:
      until:
        - condition: state
          entity_id: alarm_control_panel.alarmo
          state: disarmed
      sequence:
        - service: media_player.play_media
          data:
            media_content_id: xxxxxxxxxxxxxxx
            media_content_type: skill
          entity_id: all
        - delay:
            hours: 0
            minutes: 0
            seconds: 32
            milliseconds: 0 
  - service: scene.turn_on
    data: {}
    entity_id: 'scene.before1,scene.before2'
  - service: notify.alexa_media_everywhere
    data:
      message: Alarm disarmed
      data:
        type: announce
        method: all    
mode: single

It works but unfortunately the alarm sound is stopped after the skill has finished (30 sec) and the lamp does not return to the initial state.
Afterwards I can also lower the volume to 0 but it is not clean
I will put that light goes into normal mode and then goes out.

try splitting up the automation like efore

When splitted, i have return to the initial state faster but with same problem on light.room1 and Alexa doesn’t speak and don’t stop sound of alarm.

Please try to call alexa notify from the developer console and see. If that is working then hit the execute button in the second automation and see.

the announcements do not stop the current skill. they are done after