Merge pull request #1868 from bflorian/DVCSMP-2399-zooz-zen20-staging

DVCSMP Check for null device and send refresh() from configure()
This commit is contained in:
Vinay Rao
2017-04-03 16:48:44 -07:00
committed by GitHub

View File

@@ -25,6 +25,7 @@ metadata {
capability "Refresh" capability "Refresh"
capability "Actuator" capability "Actuator"
capability "Sensor" capability "Sensor"
capability "Configuration"
fingerprint manufacturer: "015D", prod: "0651", model: "F51C", deviceJoinName: "Zooz ZEN 20 Power Strip" fingerprint manufacturer: "015D", prod: "0651", model: "F51C", deviceJoinName: "Zooz ZEN 20 Power Strip"
} }
@@ -65,6 +66,10 @@ def updated() {
} }
} }
def configure() {
refresh()
}
////////////////////// //////////////////////
// Event Generation // // Event Generation //
@@ -107,15 +112,17 @@ def zwaveBinaryEvent(cmd, endpoint) {
def result = [] def result = []
def children = childDevices def children = childDevices
def childDevice = children.find{it.deviceNetworkId.endsWith("$endpoint")} def childDevice = children.find{it.deviceNetworkId.endsWith("$endpoint")}
childDevice.sendEvent(name: "switch", value: cmd.value ? "on" : "off") if (childDevice) {
childDevice.sendEvent(name: "switch", value: cmd.value ? "on" : "off")
if (cmd.value) { if (cmd.value) {
// One on and the strip is on // One on and the strip is on
result << createEvent(name: "switch", value: "on") result << createEvent(name: "switch", value: "on")
} else { } else {
// All off and the strip is off // All off and the strip is off
if (! children.any { it.currentValue("switch") == "on" }) { if (!children.any { it.currentValue("switch") == "on" }) {
result << createEvent(name: "switch", value: "off") result << createEvent(name: "switch", value: "off")
}
} }
} }
result result