Created
March 1, 2013 16:56
-
-
Save joshareed/5066046 to your computer and use it in GitHub Desktop.
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
/** | |
* Scheduled On and Off | |
* | |
* Author: SmartThings | |
*/ | |
def preferences() | |
{ | |
return [ | |
sections: [ | |
[ | |
title: "Turn the lights on at...", | |
input: [ | |
[ | |
name: "onAt", | |
title: "When?", | |
type: "time", | |
description: "Tap to set", | |
multiple: false | |
] | |
] | |
], | |
[ | |
title: "Turn the lights off at...", | |
input: [ | |
[ | |
name: "offAt", | |
title: "When?", | |
type: "time", | |
description: "Tap to set", | |
multiple: false | |
] | |
] | |
], | |
[ | |
title: "The lights to turn on/off...", | |
input: [ | |
[ | |
name: "switches", | |
title: "Switches?", | |
type: "capability.switch", | |
description: "Tap to set", | |
multiple: true | |
] | |
] | |
] | |
] | |
] | |
} | |
def installed() { | |
log.debug "Installed" | |
schedule(onAt, 'turnOn') | |
schedule(offAt, 'turnOff') | |
} | |
def updated() { | |
log.debug "Updated" | |
unschedule() | |
schedule(onAt, 'turnOn') | |
schedule(offAt, 'turnOff') | |
} | |
def turnOn() { | |
log.debug "Turning on switches now!" | |
switches.on() | |
} | |
def turnOff() { | |
log.debug "Turning off switches now!" | |
switches.off() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment