From 5ad2ac0492d79ee781b2f9e2e8b239060a55aa05 Mon Sep 17 00:00:00 2001 From: "Marta Wierzbinska/Home IoT Development (IoT) /SRPOL/Professional/Samsung Electronics" Date: Mon, 1 Jun 2020 09:55:31 +0200 Subject: [PATCH 1/3] ICP-13231 removed cause of duplicated events --- .../zwave-multi-button.src/zwave-multi-button.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy index f38df606963..e220e28f240 100644 --- a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy +++ b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy @@ -74,7 +74,7 @@ def initialize() { if(childDevices) { def event for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) { - event = createEvent(name: "button", value: "pushed", isStateChange: true) + event = createEvent(name: "button", value: "pushed", isStateChange: true, displayed: false) sendEventToChild(endpoint, event) } } @@ -137,9 +137,9 @@ def zwaveEvent(physicalgraph.zwave.commands.sceneactivationv1.SceneActivationSet def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotification cmd) { def value = eventsMap[(int) cmd.keyAttributes] def description = "Button no. ${cmd.sceneNumber} was ${value}" - def event = createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true) - sendEventToChild(cmd.sceneNumber, event) - return event + def childEvent = createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true) + sendEventToChild(cmd.sceneNumber, childEvent) + return createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true, displayed: false) } def sendEventToChild(buttonNumber, event) { From 6691e4578efab1b22e2ae5aba2a59932d96d3b51 Mon Sep 17 00:00:00 2001 From: "Marta Wierzbinska/Home IoT Development (IoT) /SRPOL/Professional/Samsung Electronics" Date: Mon, 8 Jun 2020 18:43:13 +0200 Subject: [PATCH 2/3] moved adding child devices to configure function --- .../zwave-multi-button.groovy | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy index e220e28f240..203762848da 100644 --- a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy +++ b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy @@ -61,23 +61,12 @@ def updated() { def initialize() { - def numberOfButtons = prodNumberOfButtons[zwaveInfo.prod] - sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false) if(isUntrackedAeotec() || isUntrackedFibaro()) { sendEvent(name: "DeviceWatch-Enroll", value: JsonOutput.toJson([protocol: "zwave", scheme:"untracked"]), displayed: false) } else { sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 10 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID]) } - if(!childDevices) { - addChildButtons(numberOfButtons) - } - if(childDevices) { - def event - for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) { - event = createEvent(name: "button", value: "pushed", isStateChange: true, displayed: false) - sendEventToChild(endpoint, event) - } - } + response([ secure(zwave.batteryV1.batteryGet()), "delay 2000", @@ -97,9 +86,24 @@ def configure() { //Makes Fibaro KeyFob buttons send all kind of supported events } } + setupChildDevices() cmds } +def setupChildDevices(){ + def numberOfButtons = prodNumberOfButtons[zwaveInfo.prod] + sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false) + if(!childDevices) { + addChildButtons(numberOfButtons) + } + if(childDevices) { + for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) { + def event = createEvent(name: "button", value: "pushed", isStateChange: true) + sendEventToChild(endpoint, event) + } + } +} + def parse(String description) { def result = [] if (description.startsWith("Err")) { From 9cfc543517807a276ca97404eb9d3404d6dcaf18 Mon Sep 17 00:00:00 2001 From: "Marta Wierzbinska/Home IoT Development (IoT) /SRPOL/Professional/Samsung Electronics" Date: Tue, 9 Jun 2020 16:23:13 +0200 Subject: [PATCH 3/3] Moved creating child events to after adding a child --- .../zwave-multi-button.src/zwave-multi-button.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy index 203762848da..ba28da45259 100644 --- a/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy +++ b/devicetypes/smartthings/zwave-multi-button.src/zwave-multi-button.groovy @@ -95,8 +95,7 @@ def setupChildDevices(){ sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false) if(!childDevices) { addChildButtons(numberOfButtons) - } - if(childDevices) { + for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) { def event = createEvent(name: "button", value: "pushed", isStateChange: true) sendEventToChild(endpoint, event)