Only trigger action if certain time has passed?

I have been fiddling around with getting a solution to this problem, but not found any.

This is my setup: I have a PIR sensor covering the area leading up to my front door. If someone approaches the house, it triggers and plays a sound, so I know someone is there. However, to not annoy me when the motion is expected, I want to limit this action to happening:

  1. only if it has passed a certain time (let’s say 5 minutes) since the last time the “someone approaching” sound was made, otherwise it gets played all the time when someone stands outside the door chatting for a while,
  2. nor play if the door magnet sensor has indicated the door has been opened (since then the motion is due to someone leaving the house), for a certain time (let’s say 1-2 minutes).

I’ve looked at solution to “rate limiting” but they all basically assume that it’s just a single trigger that should limit the rate, here I’m trying to get either the PIR sensor or the magnet sensor to inhibit the rule for a time. Anyone got any ideas?

There may be a cleaner solution, but the first thing that springs to mind for me is an input boolean.

On the automation that plays the sound, add a condition that the boolean is off and then an action to turn it on after the sound has played.

Then create a second automation that triggers when the boolean is switched on, delays for 5 minutes, then switches the boolean off again.

Hope this helps.

… Or possibly you could switch the boolean on, delay 5 minutes and then switch it off all as actions in the original automation.

Thanks @anon43302295! I was thinking along those line but didn’t really get it all together. Now I’m creating an “inhibit_motion_report”, using the suggestion from Limit automation triggering to make sure it’s not triggered while being restored, which would mess up things.

It’s still not really correct - if the motion report is inhibited, and the time for that is almost up, and the door is opened, then I would want the timer to start over again. But it’s unlikely to happen often enought to be a problem :slight_smile:

1 Like

A third automation that triggers when the door is opened, checks that the boolean is on, then switches the boolean off, then on again would restart the timer and solve the latter problem :thumbsup: