I’ve got an alarm. What I want to do is when the manual alarm state is triggered send a notification and show what trigger caused it to alarm. Seems most just alarm when a trigger fires and the alarm is set to away. The difference is that doesn’t honor the delay or any future options alarm may implement.
So I tried doing something like this:
- alias: 'Trigger alarm while armed'
trigger:
- platform: state
entity_id: sensor.front_door # Front Door
condition:
condition: or
conditions:
- condition: state
entity_id: alarm_control_panel.alarm
state: armed_away
- condition: state
entity_id: alarm_control_panel.alarm
state: armed_home
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.alarm
- alias: 'Notify when triggered'
trigger:
- platform: state
entity_id: alarm_control_panel.alarm
to: 'triggered'
action:
- service: notify.notifier
data_template:
message: >-
{%- for state in states.sensor if state.entity_id == trigger.entity_id -%}
{{ state.attributes.friendly_name }} was triggered.
{%- endfor -%}
The problem is I don’t see how i can update the notifier message to show what device caused the alarm to invoke. Curious if anyone has a solution for this.
Yes I have. The problem is that triggers the second the door is opened. I want to honor HA’s trigger_delay as specified in the manual alarm. So I setup the first automation to trigger. Then another automation to fire on trigger.
Ok, got it. I am not familiar with the HA Manual Alarm or whether is stores the triggered item.
Another option if you cannot get the item that triggered the alarm is to create a hidden binary sensor for each opening. If the alarm is armed, set the binary sensor to ‘on’ for the associated opening. Then loop through the hidden binary sensor in your alarm panel automation. Don’t forget the ensure all the hidden binary sensors are ‘off’ when you disarm the alarm.
Anyone know how this is intended to work? Looking through cookbook examples I don’t see anyone honoring the trigger time. Curious what the dev’s intended here.
@walrus_parka can you explain me why you used the automation to ‘cancel the script’?
It should be executed only if alarm is armed home/away by the first automation (conditions are 'armed_home or armed_away) without the need of the second one…
although this is already an old topic, here my solution that works with HA 0.82.1:
Create an input_text for your triggered devices.
I use a separate input_text.yaml and enabled it in my configuration.yaml with the line input_text: !include input_texts/input_text.yaml
My input_text.yaml:
alarm_trigger:
name: Alarm Trigger
initial: ""
My automation that triggers the alarm, alarm_triggers.yaml:
This is a good solution but sounds to me like an expensive work-around, it doesn’t cover more complex scenario like taking a snapshot when the sensors are triggered and anyway requires set/unset the variables every time we use them.
Using external variables makes things more difficult than they are, and maintenance of the code grows a lot.