Turn off lights after specified amount of inactivity?


(Edgespresso) #1

I have recently installed zwave dimmers (Evolve LRM-AS) in all of my bedrooms. They work great.

I am looking for an app to turn off the lights after a specified amount on inactivity. So, for example, if my son leaves his lights on and leaves the room, they will turn off after 5 minutes.

I have tried the built-in dashboard app, but that app wants to turn the lights ON & OFF based on motion.

Thanks for any suggestions.
Edge


(Ben Edwards) #2

Are you using Android? There are now easier ways to find these scenarios in iOS and in a very short time (this month) they will come to Android.


(Edgespresso) #3

Hi Ben. Thanks for the quick response!

I am using iOS (and have the latest version). Does this capability exist? I can only find the scenario where I can turn lights BOTH on & off based on motion. I only want to turn off.


(Asher) #4

I was using the app darken behind me to do this but after the iOS update I can’t find it. Where did it go?


(Andrew Urman) #5

Light Follows Me would also work.


(Asher) #6

It would but that one is nowhere to be found as we’ll. where did all the apps go? I hit the big plus button and search and they don’t pop up. I also hunted for them manually but nothing.


(Andrew Urman) #7

It’s right in the…oh wait

@Ben ?


(Ben Edwards) #8

There are a few apps that have been culled from the catalog due to redundant functionality but I am looking into a few of these specifically. In the mean time, here is the code from them:

/**
 *  Darken Behind Me
 *
 *  Author: SmartThings
 */
preferences {
	section("When there's no movement...") {
		input "motion1", "capability.motionSensor", title: "Where?"
	}
	section("Turn off a light...") {
		input "switch1", "capability.switch", multiple: true
	}
}

def installed()
{
	subscribe(motion1, "motion.inactive", motionInactiveHandler)
}

def updated()
{
	unsubscribe()
	subscribe(motion1, "motion.inactive", motionInactiveHandler)
}

def motionInactiveHandler(evt) {
	switch1.off()
}

and

/**
 *  Light Follows Me
 *
 *  Author: SmartThings
 */

preferences {
	section("Turn on when there's movement..."){
		input "motion1", "capability.motionSensor", title: "Where?"
	}
	section("And off when there's been no movement for..."){
		input "minutes1", "number", title: "Minutes?"
	}
	section("Turn on/off light(s)..."){
		input "switches", "capability.switch", multiple: true
	}
}

def installed() {
	subscribe(motion1, "motion", motionHandler)
}

def updated() {
	unsubscribe()
	subscribe(motion1, "motion", motionHandler)
}

def motionHandler(evt) {
	log.debug "$evt.name: $evt.value"
	if (evt.value == "active") {
		log.debug "turning on lights"
		switches.on()
	} else if (evt.value == "inactive") {
		runIn(minutes1 * 60, scheduleCheck, [overwrite: false])
	}
}

def scheduleCheck() {
	log.debug "schedule check"
	def motionState = motion1.currentState("motion")
    if (motionState.value == "inactive") {
        def elapsed = now() - motionState.rawDateCreated.time
    	def threshold = 1000 * 60 * minutes1 - 1000
    	if (elapsed >= threshold) {
            log.debug "Motion has stayed inactive long enough since last check ($elapsed ms):  turning lights off"
            switches.off()
    	} else {
        	log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms):  doing nothing"
        }
    } else {
    	log.debug "Motion is active, do nothing and wait for inactive"
    }
}

(Marc) #9

Thanks for this thread, I was looking for the same functionality. One minor tweak with Darken Behind Me. I’d like to add No Motion for x Minutes then turn off lights. I am playing around with the code and can’t seem to get it working. Any ideas?


(Asher) #10

Thank you for the code but that’s a bit over my head. What’s the turn around time on that functionality being reinstated for us none programmers? Btw love the product!


(Asher) #11

FYI I’m using tha in conjunction with hue mood lighting. I have the lights set to red at night/ white during the day and I want them to turn off after I’ve left the room for a bit. If you were to add “turn off after x min” to the hue in labs that would work as well.


(Gilbert Chan) #12

Why doesn’t the dashboard light controls work? I’m assuming that it’s the automatic turn on that you want to avoid.

If this is the case, you can set to control this via modes or timeframes. May not solve your problem completely but hopefully you’ll transition to like it. It takes a little getting use to, but I’m starting to condition myself to not touch light switches; then again, I have more sensors that some housemates are happy with :smile: .


(Asher) #13

I’m using modes already. My lights are set to come on via motion sensors. The mode the apartment is in determines what color and dim level. I want them to turn off when the room is empty.