Close a door after no motion for x minutes

Working on an automation to close my garage doors if they are open and there has been no mortion detected for 10 minutes. Trying to figure out how to deal with the edge case of the when the door is opened that my motion detector never detected motion (maybe opened remotely). In this case my trigger for the motion detector going to “off” for 10 minutes does not work because it never went to “on” in the first place.

- alias: Close Garage Doors with NO Motion
  initial_state: 'on'
  condition:
    condition: state
    entity_id: group.garage_stall_doors
    state: 'on'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d0001d6e053
    to: 'off'
    for:
      minutes: 10
      # seconds: 15
  action:
    - service: ifttt.trigger
      data: {"event":"Garage_close"}

Any advice on how to deal with this. I was thinking I could possibly manually trigger my motion detector to be sure it is “set” whenever a garage door opens - but not sure that is even possible - seems like I mght be over-thinking it.

Thanks!

My first thought is that the act of opening the garage door SHOULD set off the motion detector if the door is within sight of the motion detector.

My second thought is that you can add an additional trigger on the door state to ‘open’ for 10 minutes.

But you would also have to have a condition to prevent door close if the last update of the motion sensor was less than 10 minutes ago.

I’m using a PIR motion detector - so won’t detect if there is not a warm body :slight_smile:

I’m thinking that opening sets a 10 minute timer. Motion resets the timer. If motion is never detected, it shuts after 10 minutes from opening.

1 Like

Makes sense - how would you implement that? Do I need to create a timer that can be reset?

Thanks

Whoa whoa whoa!! I’m just the idea guy!!! I wish I could help ya out there, but I am just learning the basics of all this stuff. Maybe one of the script writing pros can chime in now…

I use a modified version of this.

What about those edge cases where the beam doesn’t detect something left under the door and it automatically closes on something?

I’m not sure how to do this with an automation. I would probably do it in appdaemon.

…but it looks like @RobDYI has the answer there.

Actually, I noticed that kitchen light timer has changed in the cookbook, try to use the old version here. This version uses a script that acts as a timer that can be reset with motion or when garage door is opened.