I’m trying to setup a system where, when any of a couple of contact sensors are opened:
- a critical alert is sent to my iPhone as a notification (via an automation), with the option to acknowledge / silence it
- if not acknowledged / silenced initially, repeated non-critical alerts are sent to the same phone via notification (via the alert integration), until the contact sensor either closes or I acknowledge / silence the ongoing alerts.
The code I’m using at the moment is as follows (with dummy sensor names):
automations:
- id: 'automation_door_opened_critical_alert'
alias: "Door Opened - Critical Alert"
trigger:
- platform: state
entity_id: binary_sensor.door_sensor
to: "on"
action:
- service: notify.mobile_app_the_matt_phone
data:
title: "Door opened!"
message: "The door has been opened!"
data:
push:
sound:
name: "default"
critical: 1
volume: 1.0
actions:
- action: "{{ alert_silence }}"
title: "SILENCE"
- id: "automation_handle_alert_silencing"
alias: "Handle alert silencing"
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ alert_silence }}"
action:
- service: notify.mobile_app_the_matt_phone
data:
title: "Alert Silenced"
message: "The most recent alert has been silenced."
- service: alert.turn_off
target:
entity_id: alert.alert_door_opened
alert:
alert_door_opened:
name: "Door is still open!"
done_message: "Door has been closed."
entity_id: binary_sensor.door_sensor
state: "on"
repeat:
- 2
can_acknowledge: true
skip_first: true
data:
actions:
- action: "{{ alert_silence }}"
title: "SILENCE"
notifiers:
- mobile_app_the_matt_phone
The parts relating to the initial critical alerts via automation are working fine - notification is shown on my phone, and if I tap its “SILENCE” action on my phone I receive the “The most recent alert has been silenced” notification + the ongoing alert doesn’t send any notifications (i.e. has been successfully turned off).
Likewise, the triggering of the ongoing alert works fine - the repeated notifications are received, and they have a “SILENCE” action attached.
However, if I tap the “SILENCE” action on these ongoing alerts, nothing happens - the automation_handle_alert_silencing automation never fires.
Any suggestions as to why it’s not working properly / how to fix?
Thanks.