Bruce, thanks for the code! Worked perfectly and I am back in my happy place again. Please post for others as I have seen this requested much since the upgrade.
Hi Bruce,
Iāve installed turn off after motion stops and it doesnāt work at all. Any idea what I could be doing wrong?
Thanks,
Joe
Any more specifics? The lights just donāt turn off? I tested it before I posted it, I will run another test now and report back.
Pretty much. Using a single motion sensor on a single outlet.
Iām also using smart lights to turn the light on, and the built in āoff afterā doesnāt work either.
The app works for me. There must be something else going on in your setup, especially if Smart Lights is failing also.
Thanks for checking.
I really canāt see what it could be.
Smart Lights works if no delay is set. So motion on, no motion off is fine. Itās just when I want motion on, no motion for 5 minutes the light doesnāt go off at all.
The sensor, outlet (light) and 1 door sensor are the only things Iāve got connected.
What type of sensor is it? You can turn on Live Logging in the IDE and see if that sensor is throwing the motion inactive event as it should. That should happen within 10 seconds of motion stopping.
The standard SmartThings one.
Itās definitely throwing the inactive event.
23:13:34 BST: debug Parse returned [name:motion, value:inactive, descriptionText:Living Room Motion Sensor motion has stopped]
Evidently, runIn()
scheduled events are failing in the UK. Several different reports of this, and thatās whatās failing with this app also, in the UK.
The problem Iām having with this feature (turn off lights after x minutes of no motion) is that it doesnāt seem to be working properly ā or at least not the same way ā after my switch to hub v2.
I have several lights in hallways set to turn on with motion, and then turn off after 2-5 minutes of no motion. This all worked perfectly fine under the old hub/app.
Now, this use case is biting us all the time, because the new one doesnāt handle it right:
- Person walks into dark hallway. Motion is detected; light turns on.
- Person leaves hallway; motion sensor registers āmotion stopsā. A timer starts (presumably), letās say this one is set to turn off after 2 minutes of no motion.
- Person re-enters hallway 90 seconds after the āmotion stopsā event. 30 seconds later, the light turns off, even though there is now motion detected in the hallway because someone is in it.
Lights turning off while thereās motion active has been driving us absolutely bananas since the hub v2 āupgradeā. I presume this is because thereās some logic error in the new Smart Lights app in which it doesnāt reset its timer/unschedule the lights off command if motion is detected again before the motion stop timer expires.
I have looked through several threads about the new buggy Smart Lights app but I havenāt seen a peep from Support. Iām not going to install a non-blessed SmartApp to āfixā this because then it has to execute in the cloud, which totally defeats the purpose of Hub v2. Given that lighting is probably one of the most commonly automated things, I imagine the scope of impact is significant. @Ben can you provide any insight?
I thought the purpose of Hub V2 was to automate your home. Most things are going to execute in the cloud anyway. Smart Lights is the exception. Except, Smart Lights has some issues, not least of which is a bug that messes up motion controlled lights. āNon-blessedā smartapps work, which the āblessedā Smart Lights does not.
You can wait until ST fixes Smart Lights, and do without automation in the interim. Or check out Motion Lighting: Motion Lighting. No matter what, if you want motion controlled lighting that works NOW, itās going to run in the cloud. Once they fix Smart Lights, small matter to remove one and replace it with the other!
For all of us haters, the feature to turn off the lights after x minutes is BACK! Scroll down the Smart Light app and you will see the Power Allowance optionā¦They have been pushing out serious fixes today
Interestingā¦Iāll take a look. I just noticed the icon is different, so I figured something is happening. Itās a more noticeable icon change with version 1.7.6 (the much more stable versionā¦)
HaHa. I figured making enough noise about it, and offering to fix their broken launch, would get them motivated!! They pushed out some other subtle fixes also.
One is that when you create a new automation in Smart Lights, when youāre done it takes you back to the list of automations you have in Smart Lights, right to the bottom of the list, where you can add the next one⦠@JDRoberts spent a fair amount of energy explaining to people how to find it again so they didnāt end up with multiple instance of Smart Lights, instead of multiple automations within a single instance of Smart Lights.
They still havenāt fixed Turn off after motion stops. They still donāt have the option of turning off after some minutes of no motion UNLESS you turned it on with the same automation.
So much for thatā¦
Sounds like more pushing is neededā¦
And they didnāt fix the between two motion events bug either. Well, maybe next time.
The fix is something they may find distasteful: a state variable that tracks the on/off status of the switches managed by the automation (not device.currentSwitch
), and a state variable used instead of unschedule()
to kill a runIn(minutes,turnOff)
thatās been launched. They told everyone months ago that unschedule()
was unreliable, and to my knowledge have never commented about it since. I just blew it off and use a state variable to know when a new motion event has occurred, and therefore NOT to execute any pending turnOff()
. My approach works, theirs doesnāt.
Thank you! This solved my problem too! I donāt know the first thing about writing my own code, but I copied and pasted yours into My SmartApps and ⦠voila! Thanks!
PSA, theyāve added this ability to the Smart Lighting smartapp. Theyāve also made it so the SL is no longer nested. As in my smartapps list has almost 100 lighting automations now. Yay! Haha