Check for null device and send refresh() from configure()

This commit is contained in:
Bob Florian
2017-03-31 14:47:10 -07:00
parent 6f411e1a3e
commit bdcaf175f0

View File

@@ -25,6 +25,7 @@ metadata {
capability "Refresh"
capability "Actuator"
capability "Sensor"
capability "Configuration"
fingerprint manufacturer: "015D", prod: "0651", model: "F51C", deviceJoinName: "Zooz ZEN 20 Power Strip"
}
@@ -65,6 +66,10 @@ def updated() {
}
}
def configure() {
refresh()
}
//////////////////////
// Event Generation //
@@ -107,6 +112,7 @@ def zwaveBinaryEvent(cmd, endpoint) {
def result = []
def children = childDevices
def childDevice = children.find{it.deviceNetworkId.endsWith("$endpoint")}
if (childDevice) {
childDevice.sendEvent(name: "switch", value: cmd.value ? "on" : "off")
if (cmd.value) {
@@ -114,10 +120,11 @@ def zwaveBinaryEvent(cmd, endpoint) {
result << createEvent(name: "switch", value: "on")
} else {
// 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
}