From f2aeb20a41150d5bfa2a46c5d387f683dab15807 Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 10:53:56 -0700 Subject: [PATCH 1/4] CHAD-5256 Update child DNIs when the parent rejoins --- .../zigbee-multi-switch.groovy | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 472bde68821..384fa4bd812 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -78,15 +78,20 @@ metadata { } def installed() { - createChildDevices() - updateDataValue("onOff", "catchall") - refresh() + createChildDevices() + updateDataValue("onOff", "catchall") + refresh() } def updated() { - log.debug "updated()" - updateDataValue("onOff", "catchall") - refresh() + log.debug "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)}") + } + } + refresh() } def parse(String description) { @@ -120,7 +125,7 @@ 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, + addChildDevice("Child Switch Health", "${device.deviceNetworkId}:${i}", device.hubId, [completedSetup: true, label: "${device.displayName[0..-2]}${i}", isComponent: false]) } } From 11fb4df3cd4276fc464f9a9d3a3a97b1e29ccbce Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 13:02:05 -0700 Subject: [PATCH 2/4] fixup --- .../zigbee-multi-switch.groovy | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 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 384fa4bd812..4bba00595e7 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -78,20 +78,20 @@ metadata { } def installed() { - createChildDevices() - updateDataValue("onOff", "catchall") - refresh() + createChildDevices() + updateDataValue("onOff", "catchall") + refresh() } def updated() { - log.debug "updated()" - updateDataValue("onOff", "catchall") - for (child in childDevices) { + log.debug "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)}") } } - refresh() + refresh() } def parse(String description) { @@ -167,12 +167,12 @@ def refresh() { if (isOrvibo()) { zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: 0xFF]) } else { - def cmds = zigbee.onOffRefresh() - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) - } - return cmds + def cmds = zigbee.onOffRefresh() + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) + } + return cmds } } @@ -209,17 +209,17 @@ def configure() { if (isOrvibo()) { //the orvibo switch will send out device anounce message at ervery 2 mins as heart beat,setting 0x0099 to 1 will disable it. def cmds = zigbee.writeAttribute(zigbee.BASIC_CLUSTER, 0x0099, 0x20, 0x01, [mfgCode: 0x0000]) - cmds += refresh() - return cmds + cmds += refresh() + return cmds } else { //other devices supported by this DTH in the future - def cmds = zigbee.onOffConfig(0, 120) - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) - } - cmds += refresh() - return cmds + def cmds = zigbee.onOffConfig(0, 120) + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) + } + cmds += refresh() + return cmds } } From c61b8a3caf6d8d3e33982552fe3ae1c3e7943ab6 Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 14:33:32 -0700 Subject: [PATCH 3/4] spacing fixup --- .../zigbee-multi-switch.groovy | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 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 4bba00595e7..d4dca5b28be 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -167,12 +167,12 @@ def refresh() { if (isOrvibo()) { zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: 0xFF]) } else { - def cmds = zigbee.onOffRefresh() - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) - } - return cmds + def cmds = zigbee.onOffRefresh() + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) + } + return cmds } } @@ -209,17 +209,17 @@ def configure() { if (isOrvibo()) { //the orvibo switch will send out device anounce message at ervery 2 mins as heart beat,setting 0x0099 to 1 will disable it. def cmds = zigbee.writeAttribute(zigbee.BASIC_CLUSTER, 0x0099, 0x20, 0x01, [mfgCode: 0x0000]) - cmds += refresh() - return cmds + cmds += refresh() + return cmds } else { //other devices supported by this DTH in the future - def cmds = zigbee.onOffConfig(0, 120) - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) - } - cmds += refresh() - return cmds + def cmds = zigbee.onOffConfig(0, 120) + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) + } + cmds += refresh() + return cmds } } From d161bcacc19047433aa052a6646eddd7a1868401 Mon Sep 17 00:00:00 2001 From: greens Date: Mon, 13 Jul 2020 14:35:25 -0700 Subject: [PATCH 4/4] spacing fixup --- .../zigbee-multi-switch.groovy | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 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 d4dca5b28be..9ee9fa06aab 100755 --- a/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy +++ b/devicetypes/smartthings/zigbee-multi-switch.src/zigbee-multi-switch.groovy @@ -167,12 +167,12 @@ def refresh() { if (isOrvibo()) { zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: 0xFF]) } else { - def cmds = zigbee.onOffRefresh() - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) - } - return cmds + def cmds = zigbee.onOffRefresh() + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i]) + } + return cmds } } @@ -209,17 +209,17 @@ def configure() { if (isOrvibo()) { //the orvibo switch will send out device anounce message at ervery 2 mins as heart beat,setting 0x0099 to 1 will disable it. def cmds = zigbee.writeAttribute(zigbee.BASIC_CLUSTER, 0x0099, 0x20, 0x01, [mfgCode: 0x0000]) - cmds += refresh() - return cmds + cmds += refresh() + return cmds } else { //other devices supported by this DTH in the future - def cmds = zigbee.onOffConfig(0, 120) - def x = getChildCount() - for (i in 2..x) { - cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) - } - cmds += refresh() - return cmds + def cmds = zigbee.onOffConfig(0, 120) + def x = getChildCount() + for (i in 2..x) { + cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i]) + } + cmds += refresh() + return cmds } }