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: ''
trigger:
- entity_id: binary_sensor.sliding_door
platform: state
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.ha_alarm
state: armed_away
action:
- 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
trigger:
- platform: state
entity_id: group.door,group.window,group.tamper
to: 'on'
condition:
- condition: template
value_template: "{{ states.alarm_control_panel.ha_alarm.state != 'disarmed' }}"
action:
- service: alarm_control_panel.alarm_trigger
data:
entity_id: alarm_control_panel.ha_alarm
- service: script.s_notify_both
data_template:
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 %}
2 Likes
- The trigger is for the manual alarm component.
- 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