From bdcaf175f0af833eb4b1f1f7a612d190472825a0 Mon Sep 17 00:00:00 2001 From: Bob Florian Date: Fri, 31 Mar 2017 14:47:10 -0700 Subject: [PATCH] Check for null device and send refresh() from configure() --- .../zooz-power-strip.groovy | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/devicetypes/smartthings/zooz-power-strip.src/zooz-power-strip.groovy b/devicetypes/smartthings/zooz-power-strip.src/zooz-power-strip.groovy index a6ee0ea..5647939 100644 --- a/devicetypes/smartthings/zooz-power-strip.src/zooz-power-strip.groovy +++ b/devicetypes/smartthings/zooz-power-strip.src/zooz-power-strip.groovy @@ -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,15 +112,17 @@ def zwaveBinaryEvent(cmd, endpoint) { def result = [] def children = childDevices 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) { - // One on and the strip is on - result << createEvent(name: "switch", value: "on") - } else { - // All off and the strip is off - if (! children.any { it.currentValue("switch") == "on" }) { - result << createEvent(name: "switch", value: "off") + if (cmd.value) { + // One on and the strip is on + result << createEvent(name: "switch", value: "on") + } else { + // All off and the strip is off + if (!children.any { it.currentValue("switch") == "on" }) { + result << createEvent(name: "switch", value: "off") + } } } result