Motion Disable When Lights Manually Turned On

Hi All,
I'm new to the Hubitat world. I have been using ISY994i with an all Insteon system for a few years. With the imminent demise (seemingly) of Insteon, I decided it was time for something more open, and Z-wave looked good to me. After that, I settled on Hubitat, since it looked like it might be similar in capabilites to ISY994i. So far I'm impressed with how much easier some things are.

But, I'm stuck trying to program something that I feel should be pretty basic. I have one light switch controlling one light, and a Z-wave motion sensor. I want to add motion sensing to the light (easy), but also have an override via the switch, whereas, if you turn on the light via the switch, it should stay on until switched off. This is a typical scenario for a porch light. Once manually turned off, motion sensing would resume.

I'm using the Motion Lighting App, and I thought one of the built in functions would do the trick, but I can't seem to get this to work. Maybe I'm missing something simple. Any ideas?

Thanks in advance.

Welcome refugee, I believe rule machine 5.1 could do what you want. Try searching the forum, I'm fairly certain someone has already figured it out

I have done this with a basement light. What I ended up doing is using a switch that had double taps. Those double taps turn on a virtual switch using one rule. Double tap up turns on the virtual switch, and double tap off turns it off.

Then use that virtual switch in the Motion Lighting app "additional switches to keep on" or whatever that exact setting is called. If the virtual switch is on, lights stay on. If virtual switch is off, the Motion Lighting works like normal.

I think the problem is that you can't use the same switch for the override as for the normal light. By using the double taps/virtual switch you can get around that.

1 Like

Excuse the 2 screenshots, I have not figured out how to grab a multi page rule. I believe this might be what you're looking for. This rule controls a bathroom vanity light with motion from a Hue sensor but the rule has a timer that is not wanted at certain times. Turning on the light from the switch disables the rule so the light stays on when needed.

If this is close to what you're looking for this may get you started in the right direction.

Edit, this is a simple automation rule.

1 Like

Thanks for all the quick replies guys! Let me digest all this and see if I can get it to work. It seems like the Rule Machine is the way most of you are doing this. I'm actually a bit surprised this isn't built into the Motion app, since this seems to me like a pretty "standard" feature for a motion light.

You'll find that there are often multiple ways to accomplish the desired result.

1 Like

It is, but the ML app from what I have experienced expects a second switch to do the override. If you use the same switch for normal operation and for the override you probably will be in a logic loop of some type.

That is why I used the double tap as it acts like a different device. You also could use an entirely different switch or even a button remote to accomplish this. The second rule I mention is to convert a button press (double tap on most devices is a button) into a switch because at the time I set this up ML did not have the button press disable feature just to the right and one row up on the outline in my second picture below.

1 Like

Would the Don't turn off if already on at the bottom also solve the problem if using the same switch?

1 Like

Hmm, maybe that would work in this case, I would certainly try it. Too many options, and too many ways to do things!

I think I did try that and there was some use case where it didn't work like I wanted to. Maybe I need to go back and try it again. Same as with the button to disable, there are new and improved options since I set things up. It works, and I rarely play with automations once they are working like I want them to.

1 Like

I tried that, and it didn't work. But then I noticed pretty much nothing was working. I stripped out all the override stuff, back to a dead simple motion circuit (what I started with). Still not working. Something is amiss. I may delete the rule completely and start over. Out of time for tonight though...

So, I got the setup working again by deleting it and setting up again. Just basic motion sensing. Then I turned on the "Don't turn off if already on" switch. I turned on the light manually, but after a time, the light still went off on its own. So, I'm not sure what this switch does, but I don't see different behavior with it on.
I'll try playing with the Rule Machine.

I think the example I showed you earlier will work for you.

Yep, it seems to:

Dead simple. Thanks!!

So, in my implementation above, there is an issue, which is this: since I am using the light-on status to inhibit the motion, the light will always go off after the predetermined time, in this case 1 minute. It won't retrigger since the light is on, which inhibits retriggering. It's only after the light goes out that it can retrigger. Not ideal.

I came up with another solution that I like better, where the motion sensor works normally, except when a global variable is set. I used a "hub variable", and set it when the switches on button is pressed, and clear it when the off button is pressed.

I wrote 3 programs:

  • one to set the flag using the on button
  • one to clear the flag using the off button
  • one to control the motion, but only if the flag is not set

Looks like this:
The first 2 are in the Rules Machine

and this is a Simple Automation Rule


Can you explain why the "image setting doesn't keep the light on until you turn it off manually, in ML?

Can you clarify if is is working as intended, and the use-case for this option if it is?

No, I can't explain it. I don't really understand what this option does. Based on it's name, it sounds like once the light is on (even if from motion), it would never go off, but that's probably not what you would want. Unfortunately I don't have time to go back and debug this, since I have something working now.

Yup - not sure myself, so that's why I tagged Bobby so he can swoop in an elucidate! :slight_smile:

I'd say there is a bug around this option. From my little test, it actually turned the light off when motion became active, which makes no sense at all. I'll look into it.

I take it back. This does work as expected (I had too many automations banging on one light).

Here's the test case:

And here are the logs from this sequence of steps:

  1. Light was turned on manually (from its device page)
  2. Motion became active
  3. Motion became inactive -- light was not turned off
  4. Light was turned off manually (again from device page); this is how the "Don't Turn Off" state is cleared, so that the ML app works normally.
  5. Motion became active, and turned on the light
  6. Motion became inactive and the light turned off.

Nowhere in this topic above did anyone post the logs to show what happens. ML makes extensive log entries to show exactly what is going on. Logging is your friend! Use it, you can see what causes most problems that way.

And btw, tag me for app issues,

For this automation feature to work -- Don't Turn Off if Already On -- it is critical that the device actually reliably reports being turned on. I hope that's obvious. The app can only respond correctly if it knows the device is on, and that happens from the app's subscription to the switch.on event from the light. Some devices don't report reliably. In that case, this can't possibly work as expected. So be certain the device is actually reporting on and off events as it should. Usually, when these sort of things don't work as expected, it's because the device is flaky. And usually, that will be due to a flaky device or a flaky mesh network to the device. Either is fatal.

How can you tell if the light is reporting reliably? FROM THE LOGS!

Interesting side note: If you look at the last two steps in the log above you will see that the light took almost 3 seconds from being commanded off to reporting off. This particular light is a Z-Wave dimmer that is outside, and it is a very slow to report device. Usually, it's just turned on at sunset and off at midnight, and it doesn't matter if it reports promptly or not. But it just goes to show that this thing has a weak mesh. A little weaker, and the app would have failed, even if the light actually turned on. If that report doesn't get back to the app, no good.


I got a second motion sensor today, and so I thought I would take another look at this, to see if the Motion App could work for me. I still see weird behavior once the "don't turn off if already on" switch is on. I think I have the exact same setup as above, except I'm setting my dimmer to 100. I see a very repeatable behavior, where every other time the light fails to come on. I see the motion active log, but no messages for the light. Once the motion inactive message comes, I do see messages for turning off the light (although it is already off). The next cycle, everything works fine.

Here's my setup:

And here are the logs:

This shows 2 failing cases with one working case in between.

Any thoughts?

Look at the app logs instead. They will say what the app is doing.

Download the Hubitat app