From aabb0a8b0a8d4f0ef0210d8ea3626dd54d3a36c9 Mon Sep 17 00:00:00 2001 From: Taejun Park Date: Fri, 18 Sep 2020 18:09:18 +0900 Subject: [PATCH 1/2] Exception handling for eZEX --- .../zigbee-multi-switch.groovy | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy index 8f4f7cd159c..3ef646ecd06 100644 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -107,6 +107,20 @@ def parse(String description) { Map eventMap = zigbee.getEvent(description) Map eventDescMap = zigbee.parseDescriptionAsMap(description) + if ( device.getDataValue("deviceJoinName") == "eZEX Switch 1") { + if (eventMap && eventMap?.name == "switch" && (eventMap?.value == "on" || eventMap?.value == "off")) { + if (eventDescMap && eventDescMap?.attrId != "0000") { + return [:] + } + } + + if (!eventMap && eventDescMap) { + if (eventDescMap?.clusterId == zigbee.ONOFF_CLUSTER && eventDescMap?.attrId != "0000") { + return [:] + } + } + } + if (!eventMap && eventDescMap) { eventMap = [:] if (eventDescMap?.clusterId == zigbee.ONOFF_CLUSTER) { From 2b91325b9812875adfa2b0d9ae74cd8302c8055a Mon Sep 17 00:00:00 2001 From: Taejun Park Date: Tue, 22 Sep 2020 11:21:10 +0900 Subject: [PATCH 2/2] Change the logic --- .../zigbee-multi-switch.groovy | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy index 3ef646ecd06..a77587676f8 100644 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -107,39 +107,19 @@ def parse(String description) { Map eventMap = zigbee.getEvent(description) Map eventDescMap = zigbee.parseDescriptionAsMap(description) - if ( device.getDataValue("deviceJoinName") == "eZEX Switch 1") { - if (eventMap && eventMap?.name == "switch" && (eventMap?.value == "on" || eventMap?.value == "off")) { - if (eventDescMap && eventDescMap?.attrId != "0000") { - return [:] - } - } - - if (!eventMap && eventDescMap) { - if (eventDescMap?.clusterId == zigbee.ONOFF_CLUSTER && eventDescMap?.attrId != "0000") { - return [:] - } - } - } - - if (!eventMap && eventDescMap) { - eventMap = [:] - if (eventDescMap?.clusterId == zigbee.ONOFF_CLUSTER) { - eventMap[name] = "switch" - eventMap[value] = eventDescMap?.value - } - } - if (eventMap) { - if (eventDescMap?.sourceEndpoint == "01" || eventDescMap?.endpoint == "01") { - sendEvent(eventMap) - } else { - def childDevice = childDevices.find { - it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.sourceEndpoint}" || it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.endpoint}" - } - if (childDevice) { - childDevice.sendEvent(eventMap) + if (eventDescMap && eventDescMap?.attrId == "0000") {//0x0000 : OnOff attributeId + if (eventDescMap?.sourceEndpoint == "01" || eventDescMap?.endpoint == "01") { + sendEvent(eventMap) } else { - log.debug "Child device: $device.deviceNetworkId:${eventDescMap.sourceEndpoint} was not found" + def childDevice = childDevices.find { + it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.sourceEndpoint}" || it.deviceNetworkId == "$device.deviceNetworkId:${eventDescMap.endpoint}" + } + if (childDevice) { + childDevice.sendEvent(eventMap) + } else { + log.debug "Child device: $device.deviceNetworkId:${eventDescMap.sourceEndpoint} was not found" + } } } }