Skip to content

Instantly share code, notes, and snippets.

@danlieberman
Last active December 19, 2015 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlieberman/6003813 to your computer and use it in GitHub Desktop.
Save danlieberman/6003813 to your computer and use it in GitHub Desktop.
Reset SmartApp with AppTouch
/**
* ResetAppWithTouch
*
* Author: dan@smartthings.com
* Date: 2013-07-15
*/
preferences {
section("Reset this device...") {
input "switch1", "capability.switch"
}
section( "Power off for..." ) {
input name: "seconds", title: "Seconds?", type: "number"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe( app, appTouch)
}
def appTouch(evt) {
log.debug "appTouch: $evt"
doReset()
}
def doReset() {
def numMilliSeconds = seconds * 1000;
log.debug( "Delaying ${numMilliSeconds} milliseconds..." )
switch1.off()
switch1.on( delay: numMilliSeconds )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment