Ability to turn off lights after x minutes of no motion is missing

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.

1 Like

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:

  1. Person walks into dark hallway. Motion is detected; light turns on.
  2. 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.
  3. 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! :grinning:

3 Likes

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

1 Like

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.

2 Likes

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.

1 Like

So much for that…

Sounds like more pushing is needed…

1 Like

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.

2 Likes

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!

1 Like

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