-
-
Save joshualyon/a3d4332d1e3b8663bb0c50a3b1766501 to your computer and use it in GitHub Desktop.
Virtual Humidity Switch for easier authorization
This file contains 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
/* | |
Virtual Humidity Switch | |
Author: @josh (SharpTools.io) | |
Description: Basic Virtual Humidity device that comes with a Sensor capability for authorization. | |
*/ | |
metadata { | |
definition (name: "Virtual Humidity Switch", namespace: "sharptools-io", author: "Josh Lyon") { | |
capability "Actuator" | |
capability "Sensor" | |
capability "Switch" | |
capability "RelativeHumidityMeasurement" | |
command "setHumidity", ["NUMBER"] | |
} | |
preferences {} | |
} | |
def parse(String description) { | |
} | |
def on() { | |
log.trace "Executing 'on'" | |
sendEvent(name: "switch", value: "on", isStateChange: true) | |
} | |
def off() { | |
log.trace "Executing 'off'" | |
sendEvent(name: "switch", value: "off", isStateChange: true) | |
} | |
def setHumidity(value){ | |
log.trace "Executing setHumidity $value" | |
sendEvent(name: "humidity", value: value, isStateChange: true) | |
} | |
private Map buildEvent(name, value, unit=null) { | |
Map eventMap = [name: name, value: value, unit: unit, isStateChange: true] | |
return eventMap | |
} | |
def installed() { | |
on() | |
setHumidity(0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment