[RELEASE] Left in the Dark - Lights turn on with motion if an automation turned them off

smartapp_lighting

(Eric M) #1

This is a simple app that is meant to solve the following situation: If you have an automation that turns lights off after x minutes of inactivity, and you are still in the room (just not moving around), you can immediately move around a little to turn the lights back on. Limited use case, but I created it for myself and why not share it. :slightly_smiling:

I did do this in Rule Machine initially, but it required several rules to get it working and still couldn’t do things exactly how I wanted. It didn’t take much time to put this together and is a more elegant solution.

The App has a couple things to prevent false positives:

  1. It has to be an automation that triggers the light being turned off. If you turn it
    off at the switch or manually through the app, then it won’t activate.
  2. There is a configurable timeout. This timeout starts once the light is turned off.
    The default is 60 seconds, so if motion is activated more than 60 seconds after the
    lights are turned off, then it won’t turn them back on.

The App is meant to be configured with light & motion sensor “pairs”. The app refers to the “pairs” as “rooms” as I figured that would be the most common use case, but it is really just an “area” of a home.



(Jason "The Enabler" as deemed so by @Smart) #2

That’s awesome and I can see some good uses for it.

I have a question though,

I use rule machine and I have my lights activate in motion with a pending cancellable off. The absurd time out at 15 sec and 30 sec. Once they pick up motion again the turn off timer is reset.

What does this one do that will help me?

None of this is meant derogatory. I’m trying to understand use case and if it improves on what I use them I’m all over it.

Thanks


(Eric M) #3

Sorry, but what does that mean? I do not use my motions to turn lights on and do not intend to at this point. Too many scenarios where I wouldn’t want the lights to come on with motion. I use Amazon Echos to turn lights on hands free.

If I did have them turn on with motion I wouldn’t need this app I suppose.


(Jason "The Enabler" as deemed so by @Smart) #4

What this means is that when motion stops a timer starts that turns then off. If motion is sensed before the timer ends, then the timer is cancelled, only to restart when motion stops again.

I misunderstood what you meant. I took it to mean you had motion active lights that were running of. You meant automations, as in a programmed time on and off.


(Jason "The Enabler" as deemed so by @Smart) #5

Still a great app. Thank you for contributing to the community.


(Eric M) #6

Thanks, I know it is a limited use case, but wanted to put it out there anyway. If anything else, I like how I did the interface on the app (to be a little self indulgent :wink: ). Other’s mind find a good use for that.


(Eric M) #7

Made a small update today to remove the use of the SmartThings scheduler. Made it more reliable and I was able to remove quite a bit of code.


( I hate Mondays) #8

You should make a sister app too: Right in the dark. Politically correct, I’d say ;))))

Interesting approach to a common problem, nice!


(Bobby) #9

This is neat! I don’t know how I missed it. Works perfectly for my set up. Thanks for sharing…


(Eric M) #10

@ady624 @SBDOBRESCU

Thanks guys! I know it is kind of a silly app, but it solves a problem that I would occasionally run into.


(Bobby) #11

Yes, I really like your approach to avoid the runin(). That’s a nice touch!


(Bobby) #12

Hey Eric, your app gained big xAF. My wife doesn’t like the lights to come on with motion is certain rooms, but my kids always leave the lights on. So, I use your app in case someone gets caught in the dark unexpectedly. Works perfect. One thing though, I meant to look through your code, for some reason it doesn’t work with dimmers. Do you know why?


(Eric M) #13

Can you turn on the debug logging and post some of the logs up?


(Bobby) #14

Done, I’ll post something tonight…


(Bobby) #15

Here it is, not much to see. Kitchen should have turned on


(Eric M) #16

So I am not seeing a log entry for the light in the kitchen (it looks like what is labeled Kitchen is the motion sensor, right?). I am subscribing to switch off events from the selected lights:

subscribe(settings[“lights_${i}”], “switch.off”, lightEvent)

Can you look in the lights “recently” tab and see if it is saying the light is off? Also, what is the brand and which device handler are you using?


(Bobby) #17

I was just doing that too…


(Bobby) #18

So the dimmer doesn’t have device/digital. We need to figure another way?!


(Eric M) #19

I found an issue that I can see causing a problem if the dimmer takes a few seconds to ramp down after the off command is sent to it. Fixed that. Also, I added much better logging so give that version a shot.


(Bobby) #20

And, and…and it works like a pro! Thanks for your quick fix.