Last active
December 19, 2015 19:08
-
-
Save danlieberman/6003813 to your computer and use it in GitHub Desktop.
Reset SmartApp with AppTouch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ResetAppWithTouch | |
* | |
* Author: [email protected] | |
* 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