How to set Alarm Panel can only be activated after all doors are confirmed closed?

Hi all,

I would like to set HA Alarm Panel can only be activated after all doors (Door 1 & Door 2) are confirmed closed.

In my system, Alarm Panel can be activated either via MQTT physical switch (Alarm Manual Button) or HA Alarm Panel Keypad.

Scenario:

  1. All doors are closed -> User activate Alarm Panel via MQTT physical switch or HA Alarm Panel Keypad -> Alarm Panel is activated.
  2. One of the doors are not closed -> User activate Alarm Panel via MQTT physical switch or HA Alarm Panel Keypad -> Alarm Panel is NOT activated and should prompts “Door X is not closed” notifications.

In Scenario 1, it is working fine.

In Scenario 2, when I turn on via Alarm Button, although Alarm Panel is not activated, but Alarm Button state is turned on giving impression that Alarm Panel is activated. Next, turn on via HA Alarm Panel Keypad cannot check condition whether all doors are confirmed closed. So, Alarm Panel will activate in whatever situation.

So, how could I implement a checking mechanism for all doors are confirmed closed, before a user can be allowed turned on Alarm Panel via MQTT physical switch (Alarm Manual Button) or HA Alarm Panel Keypad?

Thanks.

I’ve done exactly this.
Create a group for your door sensors, then add a condition that the group’s state is off.
My automation goes like this:

- alias: 'Alarm - Stop arming when windows left open'
  initial_state: true
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      to: 'pending'
      from: 'disarmed'
  condition:
    - condition: state
      entity_id: group.door_and_window_sensors
      state: 'on'
  action:
    - service: light.turn_off
      data:
        entity_id: light.aqara_gateway_light
    - service: tts.google_say
      data_template:
        entity_id: media_player.google_home_minis
        message: |
          Please note, one or more windows are left open. Disarming alarm...
    - service: alarm_control_panel.alarm_disarm
      entity_id: alarm_control_panel.alarm
      data:
        code: !secret alarm_code
2 Likes

@lolouk44 Thanks for the info. I was finally able to set this up after your post. Instead of a voice notice I used a text message via ClickSend which also works great. Thanks again.

2 Likes