Skip to content

Instantly share code, notes, and snippets.

@joshareed
Created March 1, 2013 16:56
Show Gist options
  • Save joshareed/5066046 to your computer and use it in GitHub Desktop.
Save joshareed/5066046 to your computer and use it in GitHub Desktop.
/**
* 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