Smart lighting tweak - honor me turning the switch on


(Mike) #1

In my office, I have a motion detector and a light with a z-wave switch that is outside of the office.

I have a Smart Lighting rule to say if there is motion, turn on the light and turn it off one minute after the motion stops.

What I would like to achieve is to say “only turn the light off if the motion stops AND it was turned on by the Smart Lighting rule”. This would allow me to turn the light on, go into the office, and have the light stay on until I manually turn it off.

How can I make this work correctly?


#2

Back before rule machine was ever written, use cases of this type were some of the most common discussed in the forums. People wanted to be able to set up a use case where motion would automatically trigger a light, but they also wanted to be able to override that with a wall switch or a minimote. Some of the examples were people doing dishes in the kitchen who would register as inactive so the lights would go off too soon, and a family with the new baby where they wanted to be able to override having the lights come on with motion with a wall switch so that when the baby was put down to nap, the lights would not come back on automatically.

@bravenel (who later wrote rule machine) was a grandmaster at these, and contributed many snippets of code in the forum to handle different specific override situations. This code all still works, it’s just that it’s written for each specific situation. So you may have to tweak it to fit your own use case.

If you’re comfortable using custom code, I’d suggest searching the forums for “baby sleeping” to find an example of how an override works. Here’s the one I usually recommend:

If you’re not comfortable with custom code, that’s OK, do the same search and when you find the thread go ahead and ask for help there and other community members should be able to get something working for you.

It’s not as slick, obviously, as something with a generic UI n the mobile app, but it can definitely solve specific problems. :sunglasses:

In case someone comes across this thread who is brand-new to the whole idea of custom code, the following FAQ introduces the basic concepts, and might make the other threads easier to understand:


(Mike) #3

I forked rule machine before Bruce split, so I’m comfortable with custom code. But it seems like Smart Lighting could do this correctly.

I’m guessing I could do this with a virtual motion sensor that is tied to the light switch. Seems like a hack though.

There’s doesn’t seem to be any concept of state on ST (besides modes and SHM’s) which I totally understand why you wouldn’t include it from a design point of view, but practically it leads to some utter hacks.


#4

Oh, and here’s one of Bruce’s snippets that handles the opposite case, where you want to disable inactivity on a motion sensor turning the lights off. This one uses a minimote to override the motion sensor.