Created
April 25, 2015 23:37
-
-
Save bdwilson/2440d8627c3bd4575e84 to your computer and use it in GitHub Desktop.
Trigger Garage Floodlight to stay on for 6 hours (requires off/on/off/on sequence within 3 seconds). Used with this light: http://www.homedepot.com/p/Defiant-270-Degree-Outdoor-Motion-Activated-White-LED-Security-Floodlight-MSH27920LWDF/203303767#product_description
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
| /** | |
| * Garage Flood 6 hour on initiate | |
| * | |
| * Author: SmartThings | |
| */ | |
| definition( | |
| name: "Garage Flood 6 Hour On", | |
| namespace: "smartthings", | |
| author: "SmartThings", | |
| description: "Turn your lights off when the SmartApp is tapped or activated", | |
| category: "Convenience", | |
| iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", | |
| iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" | |
| ) | |
| preferences { | |
| section("When I touch the app, turn off...") { | |
| input "switches", "capability.switch", multiple: true | |
| } | |
| section("Time to run") { | |
| input "time1", "time" | |
| } | |
| } | |
| def installed() | |
| { | |
| unschedule() | |
| //subscribe(location, changedLocationMode) | |
| schedule(time1, appTouch) | |
| subscribe(app, appTouch) | |
| } | |
| def updated() | |
| { | |
| unsubscribe() | |
| unschedule() | |
| //subscribe(location, changedLocationMode) | |
| schedule(time1, appTouch) | |
| subscribe(app, appTouch) | |
| } | |
| //def changedLocationMode(evt) { | |
| // log.debug "changedLocationMode: $evt" | |
| //} | |
| def appTouch(evt) { | |
| def ms = 600 | |
| turnOff() | |
| startTimer(ms) | |
| turnOn() | |
| startTimer(ms) | |
| turnOff() | |
| startTimer(ms) | |
| turnOn() | |
| log.debug "Execution complete" | |
| } | |
| def turnOff() { | |
| log.debug "Turning Off" | |
| switches?.off() | |
| } | |
| def turnOn() { | |
| log.debug "Turning On" | |
| switches?.on() | |
| } | |
| def startTimer(millis) { | |
| def passed = 0 | |
| def now = new Date().time | |
| log.debug "pausing... at Now: $now" | |
| /* This loop is an impolite busywait. We need to be given a true sleep() method, please. */ | |
| while ( passed < millis ) { | |
| passed = new Date().time - now | |
| } | |
| log.debug "... DONE pausing." | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment