Disarm alarm automation

I am trying to make this automation. When door unlock, then disarm alarm. Can someone tell me whats wrong with this automation?

- alias: Disarm when unlock door
   - platform: state
     entity_id: lock.id_lock_as_150_locked
     from: 'locked'
     to: 'unlocked'
     - condition: state
       entity_id: alarm_control_panel.alarm
       state: armed_away
    service: alarm_control_panel.alarm_disarm
    entity_id: alarm_control_panel.alarm
      code: 12345

Possibly you could tell us what’s wrong? I presume it’s not working? Any errors?

When the alarm is armed and I try to unlock the door, the alarm will not disarm.

Are you sure the state is “locked” and “unlocked” and not “on” and “off”? Does ot disarm the alarm when you teigger the automation manually? ( this will skip the trigger and condition part and go directly to the action part)

Try and change the action part to this:

    service: alarm_control_panel.alarm_disarm
    entity_id: alarm_control_panel.alarm
      code: 12345
      entity_id: alarm_control_panel.alarm

I don’t know why it needs the entity_id twice, but that is how the service is setup, and that is how this works for me.

1 Like

I’m pretty sure, that if you pass data, all parameters have to be passed as data. So you can leave out the first entity_id

I believe you are right, but if you use the UI to edit the Automation, then it will not save unless you fill out the first entity_id.

Thank you! This worked

That’s not correct, I tried a bunch of automations with data where I didn’t put the entity_id into the data section in the past. HA doesn’t care, it should do it automatically. If I had more time I would provide you some working examples, but you can easily try it yourself. Maybe I’ll find some time tonight to check the alarm panel one.

I’ve been down this rabbit hole before. Read from here down (there’s an open issue at the end):


Is it not possible to pass the disarm code with secret.yaml?

thx N.

It is possible,you do it the same way as everywhere else where it is supported.


  service: alarm_control_panel.alarm_arm_away
  entity_id: alarm_control_panel.home_alarm
    code: !secret alarm_code

sure it works, but when I try to open the automation with UI I receive error loading automation (500) for all automations…

Secrets are not supported in the UI editor.

1 Like

A workaround for having automations with secrets and preventing that they are edited in the GUI is with automation secret. Automations in that file will not be editable in the GUI and thus be safe to use.

# Configuration.yaml example

# for the frontend
automation: !include automations.yaml
# for your automations with secrets
automation secret: !include secret_automations.yaml

See Automation editor exposing !secret values · Issue #3065 · home-assistant/frontend · GitHub

1 Like

Thanks Thanks :smiley: