Created
October 4, 2019 22:16
-
-
Save joshualyon/28475f2529eae870f9262a344055831a to your computer and use it in GitHub Desktop.
Timed Session Driver Example
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
/* | |
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