Skip to content

Instantly share code, notes, and snippets.

@joshualyon
Created October 4, 2019 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshualyon/28475f2529eae870f9262a344055831a to your computer and use it in GitHub Desktop.
Save joshualyon/28475f2529eae870f9262a344055831a to your computer and use it in GitHub Desktop.
Timed Session Driver Example
/*
Timed Session Example
Author: @josh (SharpTools.io)
Just a stubbed driver to test adding a switch attribute without the Switch capability.
Doesn't actually full implement the Timed Session spec as it's just to test the sessionStatus and switch events.
*/
metadata {
definition (name: "Timed Session", namespace: "sharptools-io", author: "Josh Lyon") {
capability "Actuator"
capability "Sensor"
capability "TimedSession"
attribute "switch", "ENUM", ["on", "off"]
}
preferences {}
}
def parse(String description) {
}
def cancel(){
sendEvent(name: "sessionStatus", value: "canceled", isStateChange: true)
sendEvent(name: "switch", value: "off", isStateChange: true)
}
def pause(){
sendEvent(name: "sessionStatus", value: "paused", isStateChange: true)
sendEvent(name: "switch", value: "off", isStateChange: true)
}
def setTimeRemaining(NUMBER){
//TBD
}
def start(){
sendEvent(name: "sessionStatus", value: "running", isStateChange: true)
sendEvent(name: "switch", value: "on", isStateChange: true)
}
def stop(){
sendEvent(name: "sessionStatus", value: "stopped", isStateChange: true)
sendEvent(name: "switch", value: "off", isStateChange: true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment