-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzdb5100.groovy
189 lines (156 loc) · 6.13 KB
/
zdb5100.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
Logic-Group Matrix ZDB5100
This driver is nothing near finished, but can be used as a starting point for further development
Based on https://github.com/hubitat/HubitatPublic/blob/master/examples/drivers/basicZWaveTool.groovy
WARNING!
--Setting device parameters is an advanced feature, randomly poking values to a device
can lead to unexpected results which may result in needing to perform a factory reset
or possibly bricking the device
--Refer to the device documentation for the correct parameters and values for your specific device
--Hubitat cannot be held responsible for misuse of this tool or any unexpected results generated by its use
*/
import groovy.transform.Field
metadata {
definition (name: "Logic-Group Matrix ZDB5100",namespace: "steenole", author: "Steen Ole Andersen") {
capability "PushableButton"
capability "HoldableButton"
capability "ReleasableButton"
capability "DoubleTapableButton"
command "push", ["NUMBER"]
//command "cleanup"
command "getCommandClassReport"
command "getParameterReport", [[name:"parameterNumber",type:"NUMBER", description:"Parameter Number (omit for a complete listing of parameters that have been set)", constraints:["NUMBER"]]]
command "setParameter",[[name:"parameterNumber",type:"NUMBER", description:"Parameter Number", constraints:["NUMBER"]],[name:"size",type:"NUMBER", description:"Parameter Size", constraints:["NUMBER"]],[name:"value",type:"NUMBER", description:"Parameter Value", constraints:["NUMBER"]]]
}
}
@Field Map zwLibType = [
0:"N/A",1:"Static Controller",2:"Controller",3:"Enhanced Slave",4:"Slave",5:"Installer",
6:"Routing Slave",7:"Bridge Controller",8:"Device Under Test (DUT)",9:"N/A",10:"AV Remote",11:"AV Device"
]
void parse(String description) {
hubitat.zwave.Command cmd = zwave.parse(description,[0x85:1,0x86:2])
if (cmd) {
zwaveEvent(cmd)
}
}
//Z-Wave responses
void zwaveEvent(hubitat.zwave.commands.configurationv1.ConfigurationReport cmd) {
log.info "ConfigurationReport- parameterNumber:${cmd.parameterNumber}, size:${cmd.size}, value:${cmd.scaledConfigurationValue}"
}
void zwaveEvent(hubitat.zwave.commands.versionv1.VersionCommandClassReport cmd) {
log.info "CommandClassReport- class:${ "0x${intToHexStr(cmd.requestedCommandClass)}" }, version:${cmd.commandClassVersion}"
}
String zwaveEvent(hubitat.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
hubitat.zwave.Command encapCmd = cmd.encapsulatedCommand()
if (encapCmd) {
return zwaveEvent(encapCmd)
} else {
log.warn "Unable to extract encapsulated cmd from ${cmd}"
}
}
void zwaveEvent(hubitat.zwave.commands.centralscenev3.CentralSceneNotification cmd){
if (logEnable) log.debug "CentralSceneNotification: ${cmd}"
Integer button = cmd.sceneNumber
Integer key = cmd.keyAttributes
String action
switch (key){
case 0: //pushed
action = "pushed"
break
case 1: //released, only after 2
state."${button}" = 0
action = "released"
break
case 2: //holding
if (state."${button}" == 0){
state."${button}" = 1
runInMillis(200,delayHold,[data:button])
}
break
case 3: //double tap, 4 is tripple tap
action = "doubleTapped"
break
}
if (action){
sendButtonEvent(action, button, "physical")
}
}
//void cleanup(){
// state.remove("4")
// state.remove("lastSequenceNumber")
//}
void delayHold(button){
sendButtonEvent("held", button, "physical")
}
void push(button){
sendButtonEvent("pushed", button, "digital")
}
void hold(button){
sendButtonEvent("held", button, "digital")
}
void release(button){
sendButtonEvent("released", button, "digital")
}
void doubleTap(button){
sendButtonEvent("doubleTapped", button, "digital")
}
void sendButtonEvent(action, button, type){
String descriptionText = "${device.displayName} button ${button} was ${action} [${type}]"
if (txtEnable) log.info descriptionText
sendEvent(name:action, value:button, descriptionText:descriptionText, isStateChange:true, type:type)
}
void zwaveEvent(hubitat.zwave.commands.multichannelv4.MultiChannelCmdEncap cmd) {
hubitat.zwave.Command encapCmd = cmd.encapsulatedCommand()
log.debug "Encapsulated cmd on endpoint ${cmd.sourceEndPoint}: ${encapCmd}"
}
void zwaveEvent(hubitat.zwave.Command cmd) {
log.debug "skip: ${cmd}"
}
//cmds
List<String> setParameter(parameterNumber = null, size = null, value = null){
if (parameterNumber == null || size == null || value == null) {
log.warn "incomplete parameter list supplied..."
log.info "syntax: setParameter(parameterNumber,size,value)"
} else {
return delayBetween([
secureCmd(zwave.configurationV1.configurationSet(scaledConfigurationValue: value, parameterNumber: parameterNumber, size: size)),
secureCmd(zwave.configurationV1.configurationGet(parameterNumber: parameterNumber))
],500)
}
}
List<String> getParameterReport(param = null){
List<String> cmds = []
if (param != null) {
cmds = [secureCmd(zwave.configurationV1.configurationGet(parameterNumber: param))]
} else {
0.upto(255, {
cmds.add(secureCmd(zwave.configurationV1.configurationGet(parameterNumber: it)))
})
}
log.trace "configurationGet command(s) sent..."
return delayBetween(cmds,500)
}
List<String> getCommandClassReport(){
List<String> cmds = []
List<Integer> ic = getDataValue("inClusters").split(",").collect{ hexStrToUnsignedInt(it) }
ic.each {
if (it) cmds.add(secureCmd(zwave.versionV1.versionCommandClassGet(requestedCommandClass:it)))
}
return delayBetween(cmds,500)
}
String secure(String cmd){
return zwaveSecureEncap(cmd)
}
String secure(hubitat.zwave.Command cmd){
return zwaveSecureEncap(cmd)
}
void installed(){}
void configure() {}
void updated() {}
String secureCmd(cmd) {
if (getDataValue("zwaveSecurePairingComplete") == "true" && getDataValue("S2") == null) {
return zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
} else {
return secure(cmd)
}
}