How to keep lights on, with motion continuing, when using motion sensors

I have set up an app that successfully, turns the lights on. However, they automatically go off, even if there is continuing motion. Please take a look at the steps and let know if you have suggestions. Thanks.

Clarification: I set this for 1 minute to test the app. It us usually set for 10 minutes. Even then I have the same issue.

Use Room Lights instead of RM.


So, your rule will only trigger with the first time that it goes active. The way you have it written, will always turn the light off after the delay, as you're experiencing.

You probably want something more like:

Motion active

IF (modes) THEN
On light
Wait for event motion inactive for XX minutes
Off light 

Or, as Bruce said, kick it to room lighting and use the "vary light settings per mode" option.

1 Like

Thanks for this specific suggestion. I am fairly new to Hubitat and appreciate the support. I tried your suggestion using the Rule Machine logic you suggested. It is below. This worked better than prior efforts... but still had issues: 1) The lights went out after about 2.5 minutes even though there was still motion, and 2) after the motion stopped the lights went out about 30 seconds later. Below is what I set up. Any further suggestions? Again ... many thanks.

As @bravenel said, "Use Room Lights instead of RM."


Turn on logging for this rule and post the results. Also, check the device page and see if the "In Use By" section lists another app as controlling this switch.

One small issue I see with the rule is if the light is on and within the Wait time AND you're no longer in Evening or Night AND motion goes active again the Wait will be canceled and the light won't turn off. I also prefer for the rule not to trigger when not in Evening or Night. I would make a Required Expression for Evening or Night and eliminate the IF-THEN action.

If you decide to keep the IF-THEN add an END-IF for good practice. You could add it after the On to take care of the light not turning off but I'd still prefer not to trigger the rule outside of the desired modes.

1 Like

Actually, your rule has one important difference from what @FriedCheese2006 suggested. You are using "timeout" on your "Wait." This means that the actions will move on when either the event happens or the timeout is up. You don't want this, since you actually need the event to happen. What you're looking for instead is the "and stays?" option, which will wait for the resulting state to remain for the specified duration of time.

That being said, I second Bruce's suggestion above to not use Rule Machine for this automation. It can work, but as you can see from this string of posts, it's harder to set up than nearly any other option, among other reasons. :slight_smile:


Friends, this input has been invaluable. Very helpful to focus on inactive time. Also very helpful to keep on "And stays" option. Working together is now working like a charm. Thanks very much. I will be using this logic on many lights in the house.

Do note the advice above as well: if the modem changes to a mode where you aren't turning on tje lights and motion becomes active, your delayed off will be canceled, leaving nothing here to eventually turn off the lights. This may or may not be what you want.

I'd again encourage the use of a purpose-built app for this kind of automation, another reason being that odd cases like these are usually thought through by the app developer and either handled appropriately automatically or via an in-app option. But, as usual, there is more than one way to do things, this being one--if set up as needed.


Thanks for the follow up. I am pretty new to the app. I think you are referring to the following app: Room Lighting | Hubitat Documentation.

If so, I will plow through this over the next few days. Are there any good video tutorials on this? Sometimes it's a bit easier with a video. Any suggestions on getting up to speed are welcome.

Thanks again for your support.

That is the app Bruce and I were referring to, though it's by no means the only other way this could be done. I'm not aware of any video tutorials for this app.

In this case I don't think it matters, does it? I am asking in case I don't understand something about the wait command. If it is waiting for and stays or timeout it stops the wait if the sensor goes active again, since that is the rule trigger. If it doesn't go active again and stays inactive for 5 minutes, both commands do the same thing.

It does matter--the "timeout" doesn't wait for the "inactive" event, which is crucial for an automation that you want to proceed when (or some time after) motion becomes inactive, not just some time after motion becomes active (a not-uncommon mistake people make when setting up rules for this kind of thing instead of using a purpose-built app where this logic is generally already thought through).

Resetting the wait when motion becomes active again does not solve this particular aspect of the problem, though it is useful for others.

1 Like

I asked this because I wrote up a post suggesting the same thing you did, and then as I was about to post it I decided I was wrong and deleted it. You are right, however. because the wait with timeout continues immediately after the sensor goes inactive it only waits as long as the sensor is active. So a brain fart on my part.

The app I shared earlier stopped working. So I followed your advice and looked for a packaged app. I found the "motion and mode lighting app." I put together the following simple version of the app and it seems to be working well. Will let you know if if if fails. I am hopeful. Suggestions always welcome.

1 Like

I could be wrong, but you may want to disable off during Night and Evening modes as well. Not 100% sure whether disabling on will in turn mean the off will not trigger.... I guess you will find out.

BTW, Room Lighting is what Bruce and others were referring to. This is a more recent iteration of the Motion and Mode Lighting App. It took in a few other built-in apps as well, like Groups and Scenes. Motion and Mode Lighting includes a lot of the same features in that space, with some more features and an updated interface in Room Lighting.

Thanks for the input. My intention is for the lights to only come on during the night mode (less than 10 illumination) and when there is movement... and then to go off 5 minutes after the motion stops. So far it seems to be working. Will keep you posted.

I gave the room lighting app a try. It was pretty overwhelming. Any suggestions on how to get educated how all the pieces in the room lighting app fit together. I need some kind of tutorial or assistance.

I will also give it a try on the next room I automate. I guess I just need to work through it with questions, one step at a time.

Yeah, it was a bit of learning curve for many who had used the Mode and Motion Lighting App for some time. Initially the Mode and Motion Lighting was deprecated, meaning it was not available to install, unless you had an instance of it already. It was brought back eventually, but I can't remember the exact reason. If you feel comfortable enough with Motion Lighting, perhaps start there to get used to some of the concepts and terminology, then look to migrate anything you build into RL. (I'm pretty sure you can import motion lighting rules into RL...)

1 Like