Automation help - two triggers in succession but not simultaneous

Hi all,

Bit of automation logic help please and i’m not sure how to construct the logic. The idea is having two triggers happening within a short period of time…

Available sensors:
Alarm on/off as binary sensor: alarmarmed (true/false)
Garage Side Door contact as binary sensor: garagesidedoor (true/false)

I drive into my garage, disarm the alarm and leave through a side door via the garden to the house. I would like to run an ‘arriving home via garage’ script when this happens.

The logic is basically if alarmarmed is changed from false to true then if garagesidedoor subsequently changes from false/true within, say, 5 minutes then assume i am arriving home and run a script.

Hopefully makes sense and thanks in advance.

Trigger on the garage door closing with a condition that the alarm must be off and last changed less than 5 minutes ago.

Hi tom, the ‘last changed’ is the bit of HA logic i was missing. I’ll look that up, thanks.

     - condition: template
       value_template: >
         {{ (as_timestamp(now()) - as_timestamp(alarm_control_panel.your_alarm.last_changed)) < 300 }}
1 Like