Skip to content

Instantly share code, notes, and snippets.

@tylerlange
Last active August 29, 2015 14:08
Show Gist options
  • Save tylerlange/a8fb815f2c6949546040 to your computer and use it in GitHub Desktop.
Save tylerlange/a8fb815f2c6949546040 to your computer and use it in GitHub Desktop.
/**
* Darken Behind Me
*
* Author: SmartThings
*/
definition(
name: "Darken Behind Me",
namespace: "smartthings",
author: "SmartThings",
description: "Turn your lights off after a period of no motion being observed.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/[email protected]"
)
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment