From d1fc551eaecd025b6057c9ea14aad495ceca1c73 Mon Sep 17 00:00:00 2001 From: greens Date: Wed, 22 Jul 2020 10:08:50 -0700 Subject: [PATCH 1/3] CHAD-5256 change re-addressing code There was more code using the leading 0 of child devices than I first noticed, so the leading zero in the child DNI has simply been re-added. --- .../zigbee-multi-switch.src/zigbee-multi-switch.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 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 9ee9fa06aab..ba8543ba282 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -88,7 +88,7 @@ def updated() { updateDataValue("onOff", "catchall") for (child in childDevices) { if (!child.deviceNetworkId.startsWith(device.deviceNetworkId)) { //parent DNI has changed after rejoin - child.setDeviceNetworkId("${device.deviceNetworkId}:${getChildEndpoint(child.deviceNetworkId)}") + child.setDeviceNetworkId("${device.deviceNetworkId}:0${getChildEndpoint(child.deviceNetworkId)}") } } refresh() @@ -125,7 +125,7 @@ def parse(String description) { private void createChildDevices() { def x = getChildCount() for (i in 2..x) { - addChildDevice("Child Switch Health", "${device.deviceNetworkId}:${i}", device.hubId, + addChildDevice("Child Switch Health", "${device.deviceNetworkId}:0${i}", device.hubId, [completedSetup: true, label: "${device.displayName[0..-2]}${i}", isComponent: false]) } } From 64c105311c4b48286734b41cfd42a6b1986bcf9d Mon Sep 17 00:00:00 2001 From: greens Date: Wed, 22 Jul 2020 12:08:42 -0700 Subject: [PATCH 2/3] adds a fix for devices that were migrated while this bug was active. --- .../zigbee-multi-switch.src/zigbee-multi-switch.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ba8543ba282..948433dcf8f 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -87,7 +87,8 @@ def updated() { log.debug "updated()" updateDataValue("onOff", "catchall") for (child in childDevices) { - if (!child.deviceNetworkId.startsWith(device.deviceNetworkId)) { //parent DNI has changed after rejoin + if (!child.deviceNetworkId.startsWith(device.deviceNetworkId) || + !child.deviceNetworkId.split(':')[-1].startsWith('0')) { //parent DNI has changed after rejoin child.setDeviceNetworkId("${device.deviceNetworkId}:0${getChildEndpoint(child.deviceNetworkId)}") } } From d8da99f34f978b5d321e418139f31113dfd70895 Mon Sep 17 00:00:00 2001 From: greens Date: Wed, 22 Jul 2020 16:00:51 -0700 Subject: [PATCH 3/3] add code to avoid a bug encountered if installed and updated are called in succession --- .../zigbee-multi-switch.groovy | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 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 948433dcf8f..3435eda3e68 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -87,8 +87,8 @@ def updated() { log.debug "updated()" updateDataValue("onOff", "catchall") for (child in childDevices) { - if (!child.deviceNetworkId.startsWith(device.deviceNetworkId) || - !child.deviceNetworkId.split(':')[-1].startsWith('0')) { //parent DNI has changed after rejoin + if (!child.deviceNetworkId.startsWith(device.deviceNetworkId) || //parent DNI has changed after rejoin + !child.deviceNetworkId.split(':')[-1].startsWith('0')) { child.setDeviceNetworkId("${device.deviceNetworkId}:0${getChildEndpoint(child.deviceNetworkId)}") } } @@ -124,10 +124,12 @@ def parse(String description) { } private void createChildDevices() { - def x = getChildCount() - for (i in 2..x) { - addChildDevice("Child Switch Health", "${device.deviceNetworkId}:0${i}", device.hubId, - [completedSetup: true, label: "${device.displayName[0..-2]}${i}", isComponent: false]) + if (!childDevices) { + def x = getChildCount() + for (i in 2..x) { + addChildDevice("Child Switch Health", "${device.deviceNetworkId}:0${i}", device.hubId, + [completedSetup: true, label: "${device.displayName[0..-2]}${i}", isComponent: false]) + } } }