Rule Help: Auto Turn Off Light That Stays on for X Minutes

I need help creating a rule.

I have a security camera in the kitchen, but at night the kids like to leave the pantry light on which blinds the camera so I can’t see anything.

I added an ecosmart smart bulb to the pantry, I want to create a rule where it automatically turns off after 5 minutes during the night.

I created the rule, I believe correctly. but I cannot get it to execute properly. I adjusted the time to current time to test it and it does nothing.

Hi @Alex_Burrows, can you post a screenshot of your rule so I can better understand where it went wrong? And here is an quick example, and please note that I changed the IF_Condition logic from “ALL” (AND) to “ANY” (OR) so it will execute the following activities if it’s after sunset or before sunrise.

Yours is definitely more simple!
I don’t know how to do a rolling screen shot, so you get three :upside_down_face:

And in reverse order…

I see. You can use “state_stays” in the trigger, instead of the if_condition in the flow in this case. See below for example. So the issue of the original rule is the rule gets triggered whenever the light is turned on, and immediately checks if the light has been on for the past 10 seconds, which will never be satisfied since the light was just turned on. So using the “stays” in the trigger will execute the flow only if the light has been on for 10 seconds. Then it will check the time and decide if it should turn it off in the example below. Let me know if this helps. :grinning:

1 Like

Yes, I understand and makes sense!
I ended up just copying your rule and it worked wonderfully!
I originally tried a delay, but I had it after not before, so I just stopped using it.

Thank you James!


I hope you don’t mind that I reordered the screenshots so they’re easier to read. :wink:

The ‘State Stays’ trigger might be better in this case as it will only turn the light off if the light has stayed on for the desired period of time.

The version that triggers when the light turns on and then runs a delay could have the unintentional side-effect of turning the light off on someone who just turned it on again (eg. the last invocation of the rule happened ~5 minutes before they turned the light on). The ‘state stays’ version would avoid this. :slight_smile:

1 Like

Don’t mind at all!
That’s a good point, Josh! I’ll play around with the rule tomorrow.

1 Like

It’s amazing how fast James and Josh respond to our questions.

Thank you guys.


Agreed, it’s amazing! They are awesome.