forked from GeorgeCastanza/Nue-Zigbee-drivers-for-Hubitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nue Triple 3.4
266 lines (218 loc) · 9.03 KB
/
Nue Triple 3.4
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/**
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Based on on original by Lazcad / RaveTam
* Mods for Hui 3 Gang Switch by Netsheriff
* Mods for Preferences to change Endpoint without driver edit by scrytch
*/
metadata {
definition (name: "NUE ZigBee Wall Switch 3 Gang V.3.5", namespace: "Hubitat", author: "George Castanza") {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability "Switch"
capability "Health Check"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15A", deviceJoinName: "Leviton Lumina RF Plug-In Appliance Module"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15S", deviceJoinName: "Leviton Lumina RF Switch"
attribute "lastCheckin", "string"
attribute "switch", "string"
attribute "switch1", "string"
attribute "switch2", "string"
attribute "switch3", "string"
command "on0"
command "off0"
command "on1"
command "off1"
command "on2"
command "off2"
command "on3"
command "off3"
command "on"
command "off"
attribute "switch1","ENUM",["on","off"]
attribute "switch2","ENUM",["on","off"]
attribute "switch3","ENUM",["on","off"]
attribute "switchstate","ENUM",["on","off"]
}
}
preferences {
input("epid1", "text", title: "NUE Endpoint ID Switch 1", description: "[Endpoint ID of your NUE Zigbee Switch Button 1]", required: true)
input("epid2", "text", title: "NUE Endpoint ID Switch 2", description: "[Endpoint ID of your NUE Zigbee Switch Button 2]", required: true)
input("epid3", "text", title: "NUE Endpoint ID Switch 3", description: "[Endpoint ID of your NUE Zigbee Switch Button 3]", required: true)
input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
}
// Parse incoming device messages to generate events
def parse(String description) {
// log.debug "Parsing '${description}'"
def value = zigbee.parse(description)?.text
// log.debug "Parse: $value"
Map map = [:]
if (description?.startsWith('catchall:')) {
map = parseCatchAllMessage(description)
}
else if (description?.startsWith('read attr - ')) {
map = parseReportAttributeMessage(description)
}
else if (description?.startsWith('on/off:')){
// log.debug "onoff"
def refreshCmds = zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: "0x${epid1}"]) +
zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: "0x${epid2}"]) +
zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: "0x${epid3}"])
return refreshCmds.collect { new hubitat.device.HubAction(it) }
//def resultMap = zigbee.getKnownDescription(description)
//log.debug "${resultMap}"
//map = parseCustomMessage(description)
}
// log.debug "Parse returned $map"
// send event for heartbeat
def now = new Date()
sendEvent(name: "lastCheckin", value: now)
def results = map ? createEvent(map) : null
return results;
}
private Map parseCatchAllMessage(String description) {
Map resultMap = [:]
def cluster = zigbee.parse(description)
// log.debug cluster
if (cluster.clusterId == 0x0006 && cluster.command == 0x01){
if (cluster.sourceEndpoint == "0x${epid1}")
{
log.debug "Its Switch one"
def onoff = cluster.data[-1]
if (onoff == 1)
resultMap = createEvent(name: "switch", value: "on")
else if (onoff == 0)
resultMap = createEvent(name: "switch", value: "off")
}
if (cluster.sourceEndpoint == "0x${epid2}")
{
log.debug "Its Switch two"
def onoff = cluster.data[-1]
if (onoff == 1)
resultMap = createEvent(name: "switch2", value: "on")
else if (onoff == 0)
resultMap = createEvent(name: "switch2", value: "off")
}
else if (cluster.sourceEndpoint == "0x${epid3}")
{
log.debug "Its Switch three"
def onoff = cluster.data[-1]
if (onoff == 1)
resultMap = createEvent(name: "switch3", value: "on")
else if (onoff == 0)
resultMap = createEvent(name: "switch3", value: "off")
}
//
}
return resultMap
}
//
private Map parseReportAttributeMessage(String description) {
Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
//log.debug "Desc Map: $descMap"
Map resultMap = [:]
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "${epid1}") {
resultMap = createEvent(name: "switch1", value: "off")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "${epid1}") {
resultMap = createEvent(name: "switch1", value: "on")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "${epid2}") {
resultMap = createEvent(name: "switch2", value: "off")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "${epid2}") {
resultMap = createEvent(name: "switch2", value: "on")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "${epid3}") {
resultMap = createEvent(name: "switch3", value: "off")
}
else if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "${epid3}") {
resultMap = createEvent(name: "switch3", value: "on")
}
return resultMap
}
def off1() {
log.info "off()"
sendEvent(name: "switch1", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x${epid1} 0x0006 0x0 {}"
}
def on1() {
log.info "on()"
sendEvent(name: "switch1", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x${epid1} 0x0006 0x1 {}"
}
def off2() {
log.info "off2()"
sendEvent(name: "switch2", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x${epid2} 0x0006 0x0 {}"
}
def on2() {
log.info "on2()"
sendEvent(name: "switch2", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x${epid2} 0x0006 0x1 {}"
}
def off3() {
log.info "off3()"
sendEvent(name: "switch3", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x${epid3} 0x0006 0x0 {}"
}
def on3() {
log.info "on3()"
sendEvent(name: "switch3", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x${epid3} 0x0006 0x1 {}"
}
def off0() {
log.info "off0()"
sendEvent(name: "switch", value: "off")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x0 {}"
}
def on0() {
log.info "on0()"
sendEvent(name: "switch", value: "on")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x1 {}"
}
def off() {
log.info "off()"
sendEvent(name: "switch", value: "off")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x0 {}"
}
def on() {
log.info "on()"
sendEvent(name: "switch", value: "on")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x1 {}"
}
def refresh() {
log.debug "refreshing"
[
"he rattr 0x${device.deviceNetworkId} 0x${epid1} 0x0006 0x0", "delay 1000",
"he rattr 0x${device.deviceNetworkId} 0x${epid2} 0x0006 0x0", "delay 1000",
"he rattr 0x${device.deviceNetworkId} 0x${epid3} 0x0006 0x0", "delay 1000",
]
}
private Integer convertHexToInt(hex) {
Integer.parseInt(hex,16)
}
private Map parseCustomMessage(String description) {
def result
if (description?.startsWith('on/off: ')) {
if (description == 'on/off: 0')
result = createEvent(name: "switch", value: "off")
else if (description == 'on/off: 1')
result = createEvent(name: "switch", value: "on")
}
return result
}