Rule Machine - Keep Lights ON with Motion

I can't seem to get this to work with Rule Machine...

If the basement lights are OFF and motion is detected, turn ON basement lights and keep the lights ON until motion stops, then start a timer that will turn lights OFF after 5 minutes, if motion is detected again reset the timer to keep the lights ON.

I'm not sure if I should use Define a Rule, Define a Trigger, or Define a Trigged Rule to accomplish this. I tried several rules including the one below but nothing works the way I want.

I think you want to do a "Pending Off" in Rule Machine.

I am just learning here too, but wanted to add, take into account what the timeout is directly in the motion sensor. You can end up with one timeout making the other somewhat irrelevant.

Yes, once the sensor goes "active" it may take a minute or more to go "inactive" after motion stops.

I don't see a "Pending Off" anywhere in rule machine. I see turn off these switches after delay (default is OFF) but nothing with pending off.

Go into the false part of the rule, and then the delay 5 minutes. You should find a slider in there, underneath called cancel on truth change.

(SLIDER ONLY APPEARS ONCE YOU INPUT A FIGURE IN THE SECTION).

Sliding the slider to true, will mean that when there is motion send from the motion sensor, it will reset the 5 min countdown to a full 5 mins).

Here's what I use for my carport lights:

Under False:

Here is the detail on the pending off:

1 Like

The idea is, if there is motion during the 5 minutes the rule is waiting after the initial motion stops, the 5 minute counter will restart. This continues to happen until there has been no motion for a full five minutes after the last motion has stopped. As noted in the messages above, this may be more than 5 minutes as the sensor may take some time to switch to inactive.

A triggered rule is not the right type. You need a normal rule for motion active. Actions when true, turn on the light. Actions when false...theres two choices that will work. First is the one @Eric.C.Miller posted above. Second is to add a delay of 5 minutes (select the cancel on truth change slider), turn light off.

I tried a rule like Eric suggested but the lights still turn off after five minutes regardless if the motion sensor is tripped again durning the 5 minute period. I think it has something to due with the "Basement Stair Lights off" now being in the ON state.

Take the Light Off condition out of the rule. As soon as the light turns on, the rule changes to false and your timer starts, regardless of motion status. You don't need to check the status of the light before you turn it on.

1 Like

I took the "Light Off" condition out of the rule and the rule worked as expected but there is a problem. If the lights are turned on physically with the switch, or turned on remotely with the Dashboard app and the motion detector subsequently detects motion the rule will trigger and turn "off" the lights after 5 minutes.
I do not want the rule to run if the lights are already ON even if motion is detected.

A lot of what you are trying to do with RM is built in to Motion Lighting. You might give that a shot instead of reinventing the wheel with RM.

I haven't used Motion Lighting. Does that have an option for Pending Off? I should experiment with it!

Yep! Something like this.

@jtodd313 here's the option in Motion Lighting that should do what you're looking for...

There's also the ability to set separate dimmer levels and delays by mode. Ignore the last delay off of 1 minute, that's a UI bug.

I deleted my posts with the bad advice for the benefit of people who may read this later.

2 Likes

That's cool (Motion Lighting). I definitely need to work with that.

2 Likes

I had to do mine with RM because I wanted different off timers depending on which lights were on. For example, in the kitchen, if the dining area lights were on, I wanted a motion timeout of 30 minutes. But if just the overhead was on, I wanted a timeout of 5 minutes. Also, I wanted to be able to "override" the motion off with dimmer levels in certain rooms. For example, if the bathroom lights are at 100%, motion won't turn them off. This is only possible in RM.

If you are trying to keep the lights on you need to have the delayed action with cancel on Truth change. And then in the true part of the rule you should add Stop Action for THIS RULE (it'll be at the top).

Here's an example from my bedroom motion off.

You have a pending off. You need to delay the delay (top of the actions selection) and toggle "Cancel on truth change"

Thank you to everyone for the suggestions but I still can't get this rule to work the way I want :frowning: