4 * Author: Kevin Tierney based on code from Gilbert Chan; numButtons added by obycode
5 * Date Created: 2014-12-18
6 * Last Updated: 2015-05-13
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at:
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
14 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
15 * for the specific language governing permissions and limitations under the License.
20 definition (name: "Securifi Key Fob", namespace: "tierneykev", author: "Kevin Tierney") {
22 capability "Configuration"
26 attribute "button2","ENUM",["released","pressed"]
27 attribute "button3","ENUM",["released","pressed"]
28 attribute "numButtons", "STRING"
30 fingerprint profileId: "0104", deviceId: "0401", inClusters: "0000,0003,0500", outClusters: "0003,0501"
35 standardTile("button1", "device.button", width: 1, height: 1) {
36 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
37 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
40 standardTile("button2", "device.button2", width: 1, height: 1) {
41 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
42 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
45 standardTile("button3", "device.button3", width: 1, height: 1) {
46 state("released", label:'${name}', icon:"st.button.button.released", backgroundColor:"#ffa81e")
47 state("pressed", label:'${name}', icon:"st.button.button.pressed", backgroundColor:"#79b821")
50 main (["button3", "button2", "button1"])
51 details (["button3", "button2", "button1"])
58 def parse(String description) {
60 if (description?.startsWith('enroll request')) {
62 List cmds = enrollResponse()
63 log.debug "enroll response: ${cmds}"
64 def result = cmds?.collect { new physicalgraph.device.HubAction(it) }
67 else if (description?.startsWith('catchall:')) {
68 def msg = zigbee.parse(description)
70 buttonPush(msg.data[0])
73 log.debug "parse description: $description"
78 def buttonPush(button){
82 def currentST = device.currentState("button")?.value
83 log.debug "Unlock button Pushed"
85 else if (button == 2) {
87 def currentST = device.currentState("button2")?.value
88 log.debug "Home button pushed"
90 else if (button == 3) {
92 def currentST = device.currentState("button3")?.value
93 log.debug "Lock Button pushed"
96 def result = createEvent(name: "button", value: "pushed", data: [buttonNumber: name], descriptionText: "$device.displayName button $name was pushed", isStateChange: true)
97 log.debug "Parse returned ${result?.descriptionText}"
102 def enrollResponse() {
103 log.debug "Sending enroll response"
105 "raw 0x500 {01 23 00 00 00}", "delay 200",
106 "send 0x${device.deviceNetworkId} 0x08 1"
113 log.debug "Config Called"
115 // Set the number of buttons to 3
116 sendEvent(name: "numButtons", value: "3", displayed: false)
119 "zcl global write 0x500 0x10 0xf0 {${device.zigbeeId}}", "delay 200",
120 "send 0x${device.deviceNetworkId} 0x08 1", "delay 1500",
121 "zdo bind 0x${device.deviceNetworkId} 0x08 0x01 0x0501 {${device.zigbeeId}} {}", "delay 500",
122 "zdo bind 0x${device.deviceNetworkId} 0x08 1 1 {${device.zigbeeId}} {}"