Motion Controlled Lighting -- ST has a bug

There is a bug in “Light Turn On Motion”, which is a shortcut SmartApp in Lights & Switches (where it appears as “Turn on when there is motion”). The bug affects dimmers that are being turned on by motion and then turned off again after x minutes of no motion. If you enter the motion detection area just as the lights are turning off from no motion, or shortly thereafter, they won’t turn back on. In fact, they won’t turn back on until after motion stops again. This creates a dead spot (in motion activation) around the time that they turn off. This is definitely a bug, it’s reproducible, is fixable, and has been reported to ST support.

I wrote a simple SmartApp called “Motion Controlled Lighting” that replicates the functionality of “Light Turn On Motion”. This app provides pretty much the same functionality, but without the bug. With this app, if you enter the motion detection area just as the lights are turning off, they will immediately come back on, as they should. There is one additional feature, the ability to select extra motion sensors that must be inactive for the “turn off when no motion” function. If you use the separate “Light Turn Off Motion” shortcut SmartApp in Lights & Switches (where it appears as “Turn off when there is no motion”) together with “Motion Controlled Lighting”, the dead spot will still exist, hence the additional feature.

The app is available on my Github:

“Motion Controlled Lighting” is a new version of “Lights Turn On Motion”, which is a shortcut SmartApp found in Lights & Switches. The latter has a bug affecting motion turning on the lights correctly around the time that they turn off. “Motion Controlled Lighting” fixes that bug while providing the same functionality (with a little bit more). As with the original shortcut app, this new app allows you to mix switches and dimmers, to specify a dimmer level for the dimmers (0 to 99), and to restrict the app by time, days, and mode.


That’s funny - I thought I was crazy the other day when they didn’t come on and I was missing something. Now I know it is an actual bug!

If I manually turn a light off with a switch as I leave the room, will the motion sensor turn the light back on when it senses me on the way out? (Just thinking of the WAF at my house - she’s fine with the automated light, but she also turns the lights out manually at times too, and if it turns itself back on right afterwards, I can see that not going over very well…)

Generally speaking, no. I do this all the time. A SmartSense motion sensor has an on-cycle of about 10 seconds; that is, it doesn’t throw a motion.inactive event until about 10 seconds after motion stops. So that’s the window of time. If you turn the lights off on the way out of the room, presumably you will be clear of the sensor within 10 seconds, so the lights won’t pop back on.

Having said that, the “dead spot” I described above can occur when the lights are turned off with the switch. And that would be true with built-in “Light Turn On Motion” and my “Motion Controlled Lighting”. Both apps have to think the light is off before they will turn it on again from motion, and both have to wait for the z-wave device to tell the system that it’s off in the case of it being turned off with the switch.

What I’ve done in those places where I use a switch as a master-off switch (or master-on) is to use an instant reporting z-wave dimmer, specifically the Leviton VRMX1. It reports a physical on or off within about 1 second, which effectively eliminates the dead spot. This matters if the switch being turned off fires an app to turn off other switches at the same time.


I made an app to deal with that… its my first and only app, so its stuck in permanent beta. But it has been working reliably for me. It allows you to set an amount of time to keep a light off if you turn it off and are still in a room. That way I can have lights come on automatically when I enter a room, but if I stay in that room and turn a light off it won’t just come back on.

Its shared in the IDE under “Smarter Motion Lights”. I am not on github, but you can find the code also in my comment history. Bruce was very helpful in getting me going, thanks Bruce.

1 Like

The defaults apps have lots of problems. Typically they will start the timer even if the light is already on, then turn them off after 5 minutes, so if you turned on the lights manually first, they won’t stay on if you enter the room. I got an app published that takes care of that a while back, so IF you toggle the light switch manually, the timer is ignored until once again you turn the lights off manually… Sorry forgot the name of the app, and I’m on the road so can’t look it up.

1 Like