Door sensor to turn light off on delay

I’ve been trying to figure out how to program an automation to accomplish what I’m trying to achieve here…

I have a door sensor on my garage entry door. I have one automation that turns on the garage light when the door is opened (between certain hours of the day).

I have another automation that turns the light off when the door is closed, after a 4 minute delay.

Use case is I open the door to get something in the garage, take the trash out, leave, etc. 4 minutes is plenty of time. But sometimes I come in and out of the house, and the issue is the light always turns off 4 minutes after the first time I opened the door…. No matter how many times I opened it in between.

What I would like to have happen is for that 4 minute delay to reset if the door is reopened during that time, but this is what I’m struggling with.

Any ideas??

1 Like

You can’t reset the delay, but you could use a virtual device to represent whether the door has been recently opened.

So, create a virtual momentary button device, let’s call it “Door Recently Opened” with an auto-revert of 4 minutes. Then in the routine for when the door opens add an additional action to turn on the virtual device.

Now in your routine for turning the lights off, change the conditions so that “Door Recently Opened” = Off is a precondition and door is closed as your trigger condition with the resulting Action being the light gets turned off.

By using the virtual momentary button, every time the door is opened, the virtual device gets turned on again and the auto-revert is reset.


This was very helpful for me. I have been trying to figure out how to replace a webcore piston that I had for my garage and this put me on the right track.

I found this thread helpful for adding the virtual momentary button: [ST Edge] vEdge Creator: a virtual device generator for end users - Devices & Integrations / Community Created Device Types - SmartThings Community

My situation is even more complex as I have two motion sensors in the garage in addition to the contact sensor on the door and I want to have any of them keep the light on. The answer is really the same though.

The one thing that I found that was hanging me up is I had to reverse the precondition and trigger condition.

I had to make the precondition being my door sensor closed and the trigger condition the momentary switch off. I feel like the precondition is a safety net and not 100% needed but I am not sure yet.

Thanks again both for the question and answer!

Makes sense you had to switch the trigger and pre-condition since the trigger needs to be a state change. Since the door was already closed, the state change of the virtual device from on to off is the trigger.

You could treat the motion sensor as if the door opened since the real goal is to answer the question “should the light be turned off now?”.

Glad this helped and must give props to @TAustin who mentioned this in another thread.

Thanks all for the feedback! Will attempt this over the weekend and will report back. I actually am going to try to incorporate a motion sensor into this as well, as another poster mentioned.