diff --git a/devicetypes/smartthings/zigbee-scene-keypad.src/zigbee-scene-keypad.groovy b/devicetypes/smartthings/zigbee-scene-keypad.src/zigbee-scene-keypad.groovy old mode 100755 new mode 100644 index d4b29993aa2..a13bd588f1d --- a/devicetypes/smartthings/zigbee-scene-keypad.src/zigbee-scene-keypad.groovy +++ b/devicetypes/smartthings/zigbee-scene-keypad.src/zigbee-scene-keypad.groovy @@ -18,7 +18,7 @@ import groovy.json.JsonOutput import physicalgraph.zigbee.zcl.DataType metadata { - definition (name: "Zigbee Scene Keypad", namespace: "smartthings", author: "SmartThings", mcdSync: true) { + definition (name: "Zigbee Scene Keypad", namespace: "smartthings", author: "SmartThings", mcdSync: true, ocfDeviceType: "x.com.st.d.remotecontroller") { capability "Actuator" capability "Button" capability "Configuration" @@ -104,7 +104,16 @@ def installed() { if (!childDevices) { addChildButtons(numberOfButtons) } - sendEvent(name: "supportedButtonValues", value: ["pushed"]) + if (childDevices) { + def event + for (def endpoint : 1..device.currentValue("numberOfButtons")) { + event = createEvent(name: "button", value: "pushed", isStateChange: true, displayed: false) + sendEventToChild(endpoint, event) + } + } + + sendEvent(name: "button", value: "pushed", isStateChange: true, displayed: false) + sendEvent(name: "supportedButtonValues", value: supportedButtonValues.encodeAsJSON(), displayed: false) } def updated() { @@ -116,19 +125,29 @@ def initialize() { } private addChildButtons(numberOfButtons) { - for (def i : 2..numberOfButtons) { + for (def endpoint : 2..numberOfButtons) { try { - String childDni = "${device.deviceNetworkId}:$i" - def componentLabel = (device.displayName.endsWith(' 1') ? device.displayName[0..-2] : device.displayName) + "${i}" - addChildDevice("Child Button", "${device.deviceNetworkId}:${i}", device.hubId, - [completedSetup: true, label: "${device.displayName} button ${i}", - isComponent: true, componentName: "button$i", componentLabel: "Button $i"]) - } catch (Exception e) { + String childDni = "${device.deviceNetworkId}:$endpoint" + def childLabel = (device.displayName.endsWith(' 1') ? device.displayName[0..-2] : device.displayName) + "${endpoint}" + def child = addChildDevice("Child Button", childDni, device.getHub().getId(), [ + completedSetup: true, + label : childLabel, + isComponent : true, + componentName : "button$endpoint", + componentLabel: "Button $endpoint" + ]) + child.sendEvent(name: "supportedButtonValues", value: supportedButtonValues.encodeAsJSON(), displayed: false) + } catch(Exception e) { log.debug "Exception: ${e}" } } } +private getSupportedButtonValues() { + def values = ["pushed"] + return values +} + private getChildCount() { if (device.getDataValue("model") == "0106-G") { return 6