@@ -30,6 +30,18 @@ metadata {
30
30
fingerprint mfr : " 0000" , cc : " 0x5E,0x25,0x27,0x32,0x81,0x71,0x60,0x8E,0x2C,0x2B,0x70,0x86,0x72,0x73,0x85,0x59,0x98,0x7A,0x5A" , ccOut :" 0x82" , ui :" 0x8700" , deviceJoinName : " Aeotec Switch 1" // Aeotec Nano Switch 1
31
31
fingerprint mfr : " 027A" , prod : " A000" , model : " A004" , deviceJoinName : " Zooz Switch" // Zooz ZEN Power Strip
32
32
fingerprint mfr : " 027A" , prod : " A000" , model : " A003" , deviceJoinName : " Zooz Switch" // Zooz Double Plug
33
+ // Raw Description zw:L type:1001 mfr:015F prod:3102 model:0201 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:1
34
+ fingerprint mfr : " 015F" , prod : " 3102" , model : " 0201" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 1-button Switch
35
+ // Raw Description zw:L type:1001 mfr:015F prod:3102 model:0202 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:2
36
+ fingerprint mfr : " 015F" , prod : " 3102" , model : " 0202" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 2-button Switch
37
+ // Raw Description zw:L type:1001 mfr:015F prod:3102 model:0204 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:4
38
+ fingerprint mfr : " 015F" , prod : " 3102" , model : " 0204" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 4-button Switch
39
+ // Raw Description zw:L type:1001 mfr:015F prod:3111 model:5102 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:1
40
+ fingerprint mfr : " 015F" , prod : " 3111" , model : " 5102" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 1-button Switch
41
+ // Raw Description zw:L type:1001 mfr:015F prod:3121 model:5102 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:2
42
+ fingerprint mfr : " 015F" , prod : " 3121" , model : " 5102" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 2-button Switch
43
+ // Raw Description zw:L type:1001 mfr:015F prod:3141 model:5102 ver:5.10 zwv:4.62 lib:03 cc:5E,85,59,8E,60,55,86,72,5A,73,25,27,70,2C,2B,5B,20,7A ccOut:5B,20,26 epc:4
44
+ fingerprint mfr : " 015F" , prod : " 3141" , model : " 5102" , deviceJoinName : " WYFY Switch 1" , mnmn : " SmartThings" , vid : " generic-switch" // WYFY Touch 4-button Switch
33
45
}
34
46
35
47
tiles(scale : 2 ){
@@ -137,6 +149,11 @@ private lateConfigure() {
137
149
encap(zwave. configurationV1. configurationSet(parameterNumber : 4 , size : 4 , scaledConfigurationValue : 600 )) // enabling kWh energy reports every 10 minutes
138
150
]
139
151
break
152
+ case " WYFY Touch" :
153
+ cmds = [
154
+ encap(zwave. configurationV1. configurationSet(parameterNumber : 2 , size : 1 , scaledConfigurationValue : 1 )) // Remebers state before power failure
155
+ ]
156
+ break
140
157
default :
141
158
cmds = [encap(zwave. configurationV1. configurationSet(parameterNumber : 255 , size : 1 , scaledConfigurationValue : 0 ))]
142
159
break
@@ -181,7 +198,6 @@ def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cm
181
198
182
199
private handleSwitchReport (endpoint , cmd ) {
183
200
def value = cmd. value ? " on" : " off"
184
-
185
201
if (isZoozZenStripV2()) {
186
202
// device also sends reports without any endpoint specified, therefore all endpoints must be queried
187
203
// sometimes it also reports 0.0 Wattage only until it's queried for it, then it starts reporting real values
@@ -195,7 +211,7 @@ private changeSwitch(endpoint, value) {
195
211
if (endpoint == 1 ) {
196
212
createEvent(name : " switch" , value : value, isStateChange : true , descriptionText : " Switch ${ endpoint} is ${ value} " )
197
213
} else {
198
- String childDni = " ${ device.deviceNetworkId} :$endpoint "
214
+ String childDni = " ${ device.deviceNetworkId} :${ endpoint} "
199
215
def child = childDevices. find { it. deviceNetworkId == childDni }
200
216
child?. sendEvent(name : " switch" , value : value, isStateChange : true , descriptionText : " Switch ${ endpoint} is ${ value} " )
201
217
}
@@ -231,8 +247,10 @@ private createMeterEventMap(cmd) {
231
247
eventMap
232
248
}
233
249
250
+ // This method handles unexpected commands
234
251
def zwaveEvent (physicalgraph.zwave.Command cmd , ep ) {
235
- log. warn " Unhandled ${ cmd} " + (ep ? " from endpoint $ep " : " " )
252
+ // Handles all Z-Wave commands we aren't interested in
253
+ log. warn " ${ device.displayName} - Unhandled ${ cmd} " + (ep ? " from endpoint $ep " : " " )
236
254
}
237
255
238
256
def on () {
@@ -243,6 +261,9 @@ def off() {
243
261
onOffCmd(0x00 )
244
262
}
245
263
264
+ // The Health Check capability uses the “checkInterval” attribute to determine the maximum number of seconds the device can go without generating new events.
265
+ // If the device hasn’t created any events within that amount of time, SmartThings executes the “ping()” command.
266
+ // If ping() does not generate any events, SmartThings marks the device as offline.
246
267
def ping () {
247
268
refresh()
248
269
}
@@ -252,20 +273,31 @@ def childOnOff(deviceNetworkId, value) {
252
273
if (switchId != null ) sendHubCommand onOffCmd(value, switchId)
253
274
}
254
275
255
- private onOffCmd (value , endpoint = 1 ) {
256
- delayBetween([
257
- encap(zwave. basicV1. basicSet(value : value), endpoint),
258
- encap(zwave. basicV1. basicGet(), endpoint),
259
- " delay 3000" ,
260
- encap(zwave. meterV3. meterGet(scale : 0 ), endpoint),
261
- encap(zwave. meterV3. meterGet(scale : 2 ), endpoint)
262
- ])
276
+ def childOn (deviceNetworkId ) {
277
+ childOnOff(deviceNetworkId, 0xFF )
263
278
}
264
279
265
- private refreshAll (includeMeterGet = true ) {
280
+ def childOff (deviceNetworkId ) {
281
+ childOnOff(deviceNetworkId, 0x00 )
282
+ }
266
283
267
- def endpoints = [1 ]
284
+ private onOffCmd (value , endpoint = 1 ) {
285
+ def cmds = []
286
+
287
+ cmds + = encap(zwave. basicV1. basicSet(value : value), endpoint)
288
+ cmds + = encap(zwave. basicV1. basicGet(), endpoint)
289
+
290
+ if (deviceIncludesMeter()) {
291
+ cmds + = " delay 3000"
292
+ cmds + = encap(zwave. meterV3. meterGet(scale : 0 ), endpoint)
293
+ cmds + = encap(zwave. meterV3. meterGet(scale : 2 ), endpoint)
294
+ }
295
+
296
+ delayBetween(cmds)
297
+ }
268
298
299
+ private refreshAll (includeMeterGet = deviceIncludesMeter()) {
300
+ def endpoints = [1 ]
269
301
childDevices. each {
270
302
def switchId = getSwitchId(it. deviceNetworkId)
271
303
if (switchId != null ) {
@@ -275,25 +307,22 @@ private refreshAll(includeMeterGet = true) {
275
307
sendHubCommand refresh(endpoints,includeMeterGet)
276
308
}
277
309
278
- def childRefresh (deviceNetworkId , includeMeterGet = true ) {
310
+ def childRefresh (deviceNetworkId , includeMeterGet = deviceIncludesMeter() ) {
279
311
def switchId = getSwitchId(deviceNetworkId)
280
312
if (switchId != null ) {
281
313
sendHubCommand refresh([switchId],includeMeterGet)
282
314
}
283
315
}
284
316
285
- def refresh (endpoints = [1 ], includeMeterGet = true ) {
286
-
317
+ def refresh (endpoints = [1 ], includeMeterGet = deviceIncludesMeter()) {
287
318
def cmds = []
288
-
289
319
endpoints. each {
290
320
cmds << [encap(zwave. basicV1. basicGet(), it)]
291
321
if (includeMeterGet) {
292
322
cmds << encap(zwave. meterV3. meterGet(scale : 0 ), it)
293
323
cmds << encap(zwave. meterV3. meterGet(scale : 2 ), it)
294
324
}
295
325
}
296
-
297
326
delayBetween(cmds, 200 )
298
327
}
299
328
@@ -339,11 +368,13 @@ private encap(cmd, endpoint = null) {
339
368
}
340
369
341
370
private addChildSwitches (numberOfSwitches ) {
371
+ log. debug " ${ device.displayName} - Executing addChildSwitches()"
342
372
for (def endpoint : 2 .. numberOfSwitches) {
343
373
try {
344
374
String childDni = " ${ device.deviceNetworkId} :$endpoint "
345
375
def componentLabel = device. displayName[0 .. -2 ] + " ${ endpoint} "
346
- addChildDevice(" Child Metering Switch" , childDni, device. getHub(). getId(), [
376
+ def childDthName = deviceIncludesMeter() ? " Child Metering Switch" : " Child Switch"
377
+ addChildDevice(childDthName, childDni, device. getHub(). getId(), [
347
378
completedSetup : true ,
348
379
label : componentLabel,
349
380
isComponent : false
@@ -357,19 +388,31 @@ private addChildSwitches(numberOfSwitches) {
357
388
def isAeotec () {
358
389
getDeviceModel() == " Aeotec Nano Switch"
359
390
}
391
+
360
392
def isZoozZenStripV2 () {
361
393
zwaveInfo. mfr. equals(" 027A" ) && zwaveInfo. model. equals(" A004" )
362
394
}
395
+
363
396
def isZoozDoublePlug () {
364
397
zwaveInfo. mfr. equals(" 027A" ) && zwaveInfo. model. equals(" A003" )
365
398
}
366
399
400
+ def isWYFYTouch () {
401
+ getDeviceModel() == " WYFY Touch"
402
+ }
403
+
367
404
private getDeviceModel () {
368
405
if ((zwaveInfo. mfr?. contains(" 0086" ) && zwaveInfo. model?. contains(" 0084" )) || (getDataValue(" mfr" ) == " 86" ) && (getDataValue(" model" ) == " 84" )) {
369
406
" Aeotec Nano Switch"
370
407
} else if (zwaveInfo. mfr?. contains(" 027A" )) {
371
408
" Zooz Switch"
409
+ } else if (zwaveInfo. mfr?. contains(" 015F" )) {
410
+ " WYFY Touch"
372
411
} else {
373
412
" "
374
413
}
375
414
}
415
+
416
+ private deviceIncludesMeter () {
417
+ return ! isWYFYTouch()
418
+ }
0 commit comments