Hello all–
I am a newb, and 3 weeks ago had no idea what HA was. With that said I’ve made some great progress except for this one concept. I’ve read at least 25 related posts, and numerous docs and still can’t wrap my head around the correct way to do this. Any pointers would be greatly appreciated.
I have an alarm panel, with internal relays that close when in alarm. One is for critical alarms, and one for non-critical. I will soon have a Shelly Uni monitoring those 2 relays, so will have HA entities defined with on and off states.
I want the following to occur. When an entity state changes from off to on, a delay begins (30 seconds for critical alarms, 5 minutes for non). I want to create a couple automations that, after the delay, I receive an email and a mobile notification. Those actions are defined and work well. The issue is, if an entity turns off and then back on during the delay period, I want the delay to restart from the beginning. Obviously if the entity stays off the automation exits and waits for a new trigger. And because the delays are so short, I’d prefer simplicity over worrying whether they get reset during a system restart, save, or something.
This is where I’m at, which is a basic starting point. I’ve tried a dozen iterations of this without the desired result. This is my first post here so I’m sure I’m posting the code incorrectly.
alias: Alarm Notification - Critical
description: Sends email and text when a critical alarm is detected after 15 seconds
trigger:
- platform: state
entity_id:
- switch.critical_alarm
to: "on"
from: "off"
for:
hours: 0
minutes: 0
seconds: 15
condition: []
action:
- service: notify.email_notification
data:
message: "Alert: Critical alarm has been triggered"
title: Home Assistant - 11223 Critical Alarm
- service: notify.mobile_app_xxxxxxx
data:
message: "Alert: Critical alarm has been triggered"
title: Home Assistant - 11223 Critical Alarm
data:
visibility: public
mode: single
There will also be a third automation that looks and both entities, and when they both go to off for 30 seconds, I will receive notifications that all has been reset. I assume that the same solution here will apply. Like I’ve said, I’ve read all of the docs on delays, triggers, mode single vs restart, etc. and nothing will restart the delay–the intervening state change from on to off and back to on is ignored.
Thanks, I really appreciate any advice.