Last active
July 10, 2019 16:26
-
-
Save joshualyon/22e7a959a15933ebf7c478139135e2da 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
/** | |
* Simulated Battery | |
* | |
* Copyright 2019 josh | |
*/ | |
metadata { | |
definition (name: "Simulated Battery", namespace: "sharptools-io", author: "josh", cstHandler: true) { | |
capability "Battery" | |
capability "Sensor" | |
capability "Actuator" | |
command "setLevel", ["NUMBER"] | |
} | |
simulator { | |
// TODO: define status and reply messages here | |
} | |
tiles { | |
// TODO: define your main and details tiles here | |
} | |
} | |
def installed(){ | |
setLevel(100) | |
} | |
// parse events into attributes | |
def parse(String description) { | |
log.debug "Parsing '${description}'" | |
// TODO: handle 'battery' attribute | |
} | |
def setLevel(level){ | |
level = level as int | |
log.debug "setLevel ${level}" | |
level = Math.max(Math.min(level, 99), 0) | |
sendEvent(name: "battery", value: level) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment