Motion Based Light EXCEPT when Manually turned On



yep, that was the one change needed so that if the wait is interrupted by motion, the light Is still turned off 5 minutes after the last motion.

If you would please add the FINAL FINAL snapshot to this thread, that would help out any users looking for something like this subsequently. :slight_smile:


FINAL Working!!!

This piston will turn on a light with motion and turn off X time after motion. If the light is manually switched on, it will stay on regardless of motion until it is switched off again (physically, Alexa, etc.)


Changed a little for my needs. Added sunset to sunrise and auto setting of variable to false if using more than 1 switch.

Backup code is qvt9p. Could not get in screenshot since using an iPad to set this up. Works like a charm, thanks @Sal


Dang it. Found a glitch



I’m using your piston, but I’m not getting an override when I turn my physical Z-wave dimmer switch on…I’m finding it’s just about impossible to turn on the switch before the sensor detects the movement. I tried turning on the switch even after it was on, but that didn’t work.

Any suggestions of additional code I can add to your piston to make it so that even if the sensor turns on the light, I can have a process to override it turning back off after motion is inactive?

I tried turn the dimmer switch off and back on, but it still turned off after the motion didn’t sense movement.


if use the original example piston. it was built for just that use case:


I’ll give it a try


How did you subscribe to a “smart bulb” that I installed and powered from a “dumb switch”?
Is it not correct in saying that when the dumb switch is OFF there is no power at the bulb, therefore how do you get a ‘if switch is physically changed to ON’??

I just tried it on a GoControl bulb and was tracking the SmartThings logs and got a big nothing when cold starting the bulb. HOWEVER I was interested to learn that when cold starting my Sylvania Lightify bulb (if and only if the bulb was not at 100% when shut off) it will turn to 100%


I can’t get this to work correctly, yet…When I first installed the piston, it worked fine, including the first time I turned off the physical z-wave dimmer and back on…that turned off the routine of turning off the light once motion stopped. However, once I did that and subsequently turned the light back off via the z-wave dimmer, the piston would no longer turn off the light after motion wasn’t detected…My preference is to not have to go into the ST app to turn the z-waver dimmer off, on, etc. in order to temporarily halt the piston routine via motion…Here’s my piston based on yours, bangali.


the example above was built for a smart bulb with a dumb switch. based on the thread above i think there is a need for an example for a smart switch with a dumb bulb. i will build an example piston and post that as part of the first post on this topic.



@smartie what you have there should actually work for a smart switch with a dumb bulb. have you tried turning trace on to see whats happening? also with trace, might be easier to see the functioning if you change the wait to 15 seconds or so instead of 5 seconds.


I’m not sure what a dumb bulb is, but I’m guessing it means the bulb itself is not automated, which would be true. I have a z-wave dimmer switch which controls the light. I need to be able to override the motion should I need to be in the room longer than what the motion is set for. Any suggestions on how to make a toggle of the physical z-wave dimmer cause the motion to not turn off the light until the light is physically turned back off via the same physical z-wave dimmer?


Thanks…that’s probably why I am not getting the intended actions…


that piston you shared should do the job:

change the wait timing and run with trace on to see what may or not be happening. when you turn the dimmer off then on wait for a second between the off and the on otherwise it may not register the off action. if memory serves me right, i have seen that happen before when i was first building something along these lines.


Thanks…I might have tried this one, but I might not have waited like you suggest…I forgot we are dealing with cloud-based actions…


yep. doesnt happen with non-dimmer switches but i have seen that happen with dimmers.


The reason I need this is I am finding if I am in the room and the motion sensor turns “off” for a second, the light goes off…I am sure there is another way to program this, but having an override seems like a nice option. Of course, if I change the amount of time the light stays on, that will avoid this, but I prefer to not have the light on for 5 minutes with no motion…


right. that was the exact use case the example piston was built for. except for that user, it a dumb switch with a smart bulb.

right, you shouldnt have to do that. we will get this to work. if you share a green snapshot, i will also restore the piston and try it myself when i am back home.


Thanks…let me mess around with your example, again, but this time be a little more patient on the off and on. Just to make sure I understand the way the piston works, let’s say I walk into the room and the motion turns the light on. I can still turn the physical switch off, wait…turn back on…and it should now be in override mode? When I turn the light back off with the physical switch, does it then revert to the motion-based piston routine?


if you look at the example i posted, the first post in this thread - it uses a smart bulb with a dumb switch. there are some bulbs which correctly report on/off state even when controlled by a dumb switch.

unfortunately, the lightify bulbs do not correctly report switch state when turned off by a dumb switch.