2 * 3 Button Remote Zigbee ZBWS3
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11 * for the specific language governing permissions and limitations under the License.
13 * Original code by GilbertChan, modified by obycode to add "numButtons"
14 * Thanks to Seth Jansen @sjansen for original contributions
17 definition (name: "3 Button Remote (ZBWS3)", namespace: "thegilbertchan", author: "Gilbert Chan") {
19 capability "Configuration"
21 attribute "button2","ENUM",["released","pressed"]
22 attribute "button3","ENUM",["released","pressed"]
23 attribute "numButtons", "STRING"
25 fingerprint endpointId: "03", profileId: "0104", deviceId: "0000", deviceVersion: "00", inClusters: "03 0000 0003 0007", outClusters: "01 0006"
34 // UI tile definitions
37 standardTile("button1", "device.button", width: 1, height: 1) {
38 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
39 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
42 standardTile("button2", "device.button2", width: 1, height: 1) {
43 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
44 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
47 standardTile("button3", "device.button3", width: 1, height: 1) {
48 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
49 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
52 main (["button3", "button2", "button1"])
53 details (["button3", "button2", "button1"])
57 // Parse incoming device messages to generate events
58 def parse(String description) {
59 log.debug "Parse description $description"
62 if (description?.startsWith("catchall: 0104 0006 01")) {
64 def currentST = device.currentState("button")?.value
65 log.debug "Button 1 pushed"
68 else if (description?.startsWith("catchall: 0104 0006 02")) {
70 def currentST = device.currentState("button2")?.value
71 log.debug "Button 2 pushed"
74 else if (description?.startsWith("catchall: 0104 0006 03")) {
76 def currentST = device.currentState("button3")?.value
77 log.debug "Button 3 pushed"
80 def result = createEvent(name: "button", value: "pushed", data: [buttonNumber: name], descriptionText: "$device.displayName button $name was pushed", isStateChange: true)
81 log.debug "Parse returned ${result?.descriptionText}"
88 def parseDescriptionAsMap(description) {
89 (description - "read attr - ").split(",").inject([:]) { map, param ->
90 def nameAndValue = param.split(":")
91 map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
95 private getFPoint(String FPointHex){ // Parsh out hex string from Value: 4089999a
96 Long i = Long.parseLong(FPointHex, 16) // Convert Hex String to Long
97 Float f = Float.intBitsToFloat(i.intValue()) // Convert IEEE 754 Single-Precison floating point
98 log.debug "converted floating point value: ${f}"
105 // Commands to device
108 // Set the number of buttons to 3
109 updateState("numButtons", "3")
111 log.debug "Binding SEP 0x01 DEP 0x01 Cluster 0x0006 On/Off cluster to hub"
114 "zdo bind 0x${device.deviceNetworkId} 0x01 0x01 0x0006 {${device.zigbeeId}} {}", "delay 500",
115 "zdo bind 0x${device.deviceNetworkId} 0x02 0x01 0x0006 {${device.zigbeeId}} {}", "delay 500",
116 "zdo bind 0x${device.deviceNetworkId} 0x03 0x01 0x0006 {${device.zigbeeId}} {}", "delay 1500",
118 log.info "Sending ZigBee Bind commands to 3 Button Switch"
124 // Store mode and settings
125 def updateState(String name, String value) {
127 device.updateDataValue(name, value)