From 23670dd9a8775d7d58e50798fa30c56a9c2e73b7 Mon Sep 17 00:00:00 2001 From: Konrad K <33450498+KKlimczukS@users.noreply.github.com> Date: Thu, 24 Oct 2019 19:05:28 +0200 Subject: [PATCH] ICP-10136 - Zooz Power Strip: calling sendHubCommand() once with all commands (for all endpoints) (#11431) * ICP-10136 - calling sendHubCommand() once with all commands (for all endpoints) * ICP-10136 - decreased delay between commands send from refresh() to 200 milliseconds --- .../zwave-multi-metering-switch.groovy | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/devicetypes/smartthings/zwave-multi-metering-switch.src/zwave-multi-metering-switch.groovy b/devicetypes/smartthings/zwave-multi-metering-switch.src/zwave-multi-metering-switch.groovy index 14b310310d9..e07d86705f1 100644 --- a/devicetypes/smartthings/zwave-multi-metering-switch.src/zwave-multi-metering-switch.groovy +++ b/devicetypes/smartthings/zwave-multi-metering-switch.src/zwave-multi-metering-switch.groovy @@ -254,26 +254,38 @@ private onOffCmd(value, endpoint = 1) { } private refreshAll(includeMeterGet = true) { - childDevices.each { childRefresh(it.deviceNetworkId, includeMeterGet) } - sendHubCommand refresh(includeMeterGet) + + def endpoints = [1] + + childDevices.each { + def switchId = getSwitchId(it.deviceNetworkId) + if (switchId != null) { + endpoints << switchId + } + } + sendHubCommand refresh(endpoints,includeMeterGet) } def childRefresh(deviceNetworkId, includeMeterGet = true) { def switchId = getSwitchId(deviceNetworkId) if (switchId != null) { - sendHubCommand refresh(switchId,includeMeterGet) + sendHubCommand refresh([switchId],includeMeterGet) } } -def refresh(endpoint = 1, includeMeterGet = true) { +def refresh(endpoints = [1], includeMeterGet = true) { - def cmds = [encap(zwave.basicV1.basicGet(), endpoint)] + def cmds = [] - if (includeMeterGet) { - cmds << encap(zwave.meterV3.meterGet(scale: 0), endpoint) - cmds << encap(zwave.meterV3.meterGet(scale: 2), endpoint) + endpoints.each { + cmds << [encap(zwave.basicV1.basicGet(), it)] + if (includeMeterGet) { + cmds << encap(zwave.meterV3.meterGet(scale: 0), it) + cmds << encap(zwave.meterV3.meterGet(scale: 2), it) + } } - delayBetween(cmds, 500) + + delayBetween(cmds, 200) } private resetAll() {