Door Opened when using manual alarm

I am trying to figure out what would be the best method to have HA send me a notification on which door has opened when my alarm is armed. Do I have to have an automation for each individual door, or can I have the door be stored as a variable and have the variable notify me in the notify message?
I currently have to have a different automation for each door, but there has to be a better method.

 alias: Alarm
  description: ''
  - entity_id: binary_sensor.sliding_door
    platform: state
    to: 'on'
  - condition: state
    entity_id: alarm_control_panel.ha_alarm
    state: armed_away
  - data:
      message: Alarm! Door Open!
    service: notify.mobile_app_samsung

I have a group for my doors, windows, and tampers for those sensors to trigger the alarm system with an automation. The example was taken from this forum some time ago.

Message appears as: “GARAGE DOOR opened at 7:30:02 AM. Alarm will trigger in 90 seconds.”

- id: alarm_warning
  alias: '[Alarm] Warning'
  initial_state: true
  - platform: state
    entity_id: group.door,group.window,group.tamper
    to: 'on'
    - condition: template
      value_template: "{{ states.alarm_control_panel.ha_alarm.state != 'disarmed' }}"
  - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm
  - service: script.s_notify_both
      title: 'WARNING'
      message: >
          {% set ts = now().strftime("%-I:%M:%S %p") %}
          {% for entity in trigger.to_state.attributes.entity_id %}
            {% if states(entity) == 'on' %}
              {{ state_attr(entity, 'friendly_name') | upper }} opened at {{ ts }}. Alarm will TRIGGER in 90 seconds.
            {% endif %}
          {% endfor %}

Couple questions.

  1. what is the alarm_control_panel.alarm_trigger actually calling? Is that just a service built into the manual alarm?
  2. I’m getting an error that trigger is undefined. Is that because I don’t have anything built into the alarm_trigger service?
  1. The trigger is for the manual alarm component.
  2. Your configuration likely does not match mine. You will have to be mindful of spacing that it matches your config. Have you defined a group for your sensors?

Have a look at the component page.

I’ve been reading the component page, just got confused on the triggered state. I think I got it now.

Apparently I needed to restart HA all together and not just use restart automation function, but it is working correctly now.

Thanks for the help!

1 Like