-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZemismart Power Meter Smart Plug.groovy
728 lines (654 loc) · 29.4 KB
/
Zemismart Power Meter Smart Plug.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
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
/*
GE Smart Plug / Zemismart Power Meter Smart Plug
Changes:
- 09/26/19 Update nname and fingerprint from @aruffell
- 09/27/19 Fix typo for reporting, and update fingerprint order, fix whitespace
- Adapted to Zemismart Power Smart Plug by Joao (@joaomf)
- https://github.com/joaomf/hubitat/edit/master/Zemismart%20Power%20Meter%20Smart%20Plug.groovy
*/
import groovy.transform.Field
@Field static Map zigbeeSwitch = [
cluster: [
name: "Switch Cluster",
hexString: "0006",
hexValue: 0x0006,
],
onOffAttr : [
name: "On/Off",
hexString: "0000",
hexValue: 0x0000,
],
]
@Field static Map zigbeeSimpleMonitoring = [
cluster: [
name: "Simple Monitoring Cluster",
hexString: "0702",
hexValue: 0x0702,
],
energyAttr : [
name: "Accumulated Energy Used",
hexString: "0000",
hexValue: 0x0000,
divisor: 200, //10000
],
energyDayAttr : [
name: "Current Day Energy Used",
hexString: "0001", //0401
hexValue: 0x0001, //0x0401
divisor: 200, //10000
],
powerAttr : [
name: "Instantaneous Power Use",
hexString: "0006", //0400
hexValue: 0x0006,
divisor: 1, //10
],
unitAttr : [
name: "Unit of Measure",
hexString: "0300", //0400
hexValue: 0x0300,
divisor: 1, //10
],
energyMultiplierAttr : [
name: "Energy Multiplier",
hexString: "0301",
hexValue: 0x0301,
divisor: 1, //10
],
energyDivisorAttr : [
name: "Energy Divisor",
hexString: "0302",
hexValue: 0x0302,
divisor: 1, //10
],
]
@Field static Map zigbeeElectricalMeasurement = [
cluster: [
name: "Electrical Measurement Cluster",
hexString: "0B04",
hexValue: 0x0B04,
],
powerrAttr : [
name: "Power",
hexString: "050B",
hexValue: 0x050B,
divisor: 2,
],
voltageAttr : [
name: "Voltage",
hexString: "0505",
hexValue: 0x0505,
divisor: 1,
],
currentAttr : [
name: "Current",
hexString: "0508",
hexValue: 0x0508,
divisor: 2000,
],
currentMultAttr : [
name: "Current Mult",
hexString: "0602",
hexValue: 0x0602,
divisor: 1,
],
currentDivAttr : [
name: "Current Div",
hexString: "0603",
hexValue: 0x0603,
divisor: 1,
],
]
@Field static List currentChangeOptions = [
"No Reports",
"0.1 A",
"0.5 A",
"1.0 A",
"2.0 A",
"3.0 A",
"4.0 A",
"5.0 A",
"6.0 A",
"7.0 A",
"8.0 A",
"9.0 A",
"10.0 A",
"20.0 A",
]
@Field static List voltageChangeOptions = [
"No Reports",
"1 Volt",
"2 Volts",
"3 Volts",
"4 Volts",
"5 Volts",
"10 Volts",
"25 Volts",
"50 Volts",
]
@Field static List powerrChangeOptions = [
"No Reports",
"1 Watt",
"2 Watts",
"3 Watts",
"4 Watts",
"5 Watts",
"10 Watts",
"25 Watts",
"50 Watts",
"100 Watts",
"200 Watts",
"500 Watts",
"1000 Watts",
]
@Field static List powerChangeOptions = [
"No Reports",
"1 Watt",
"2 Watts",
"3 Watts",
"4 Watts",
"5 Watts",
"10 Watts",
"25 Watts",
"50 Watts",
"100 Watts",
"200 Watts",
"500 Watts",
"1000 Watts",
]
@Field static List energyChangeOptions = [
"No Reports",
"0.001 kWh",
"0.005 kWh",
"0.010 kWh",
"0.025 kWh",
"0.050 kWh",
"0.100 kWh",
"0.250 kWh",
"0.500 kWh",
"1 kWh",
"2 kWh",
"5 kWh",
"10 kWh",
"20 kWh",
]
@Field static List timeReportOptions = [
"No Reports",
"5 Seconds",
"10 Seconds",
"30 Seconds",
"1 Minute",
"5 Minutes",
"15 Minutes",
"30 Minutes",
"1 Hour",
"6 Hours",
"12 Hours",
"24 Hours",
]
metadata {
definition (name: "GE/Jasco Smart Switch", namespace: "asj", author: "asj") {
capability "Configuration"
capability "Refresh"
capability "PowerMeter"
capability "EnergyMeter"
capability "CurrentMeter"
capability "Sensor"
capability "Outlet"
capability "Switch"
capability "VoltageMeasurement"
command "resetEnergy"
attribute "current", "number"
attribute "energyYesterDay", "number"
attribute "energyToday", "number"
attribute "energyMonth", "number"
// GE/Jasco
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B05,0702", outClusters: "0003,000A,0019", manufacturer: "Jasco", model: "45853", deviceJoinName: "GE ZigBee Plug-In Switch"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B05,0702", outClusters: "000A,0019", manufacturer: "Jasco", model: "45856", deviceJoinName: "GE ZigBee In-Wall Switch"
fingerprint profileId: "0104", inClusters: "0000,0004,0005,0006,0702,0B04", outClusters: "0019,000A", manufacturer: "_TZ3000_rdtixbnu", model: "TS0121", deviceJoinName: "Zemismart Outlet"
}
preferences {
//standard logging options
input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
input name: "powerChange", type: "enum", title: "Power Report Value Change:", defaultValue: powerChangeOptions[0], options: powerChangeOptions
input name: "powerReport", type: "enum", title: "Power Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "energyChange", type: "enum", title: "Energy Report Value Change:", defaultValue: energyChangeOptions[0], options: energyChangeOptions
input name: "energyReport", type: "enum", title: "Energy Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "energyDayChange", type: "enum", title: "Energy Day Report Value Change:", defaultValue: energyChangeOptions[0], options: energyChangeOptions
input name: "energyDayReport", type: "enum", title: "Energy Day Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "powerrChange", type: "enum", title: "Powerr Report Value Change:", defaultValue: powerrChangeOptions[0], options: powerrChangeOptions
input name: "powerrReport", type: "enum", title: "Powerr Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "voltageChange", type: "enum", title: "Voltage Report Value Change:", defaultValue: voltageChangeOptions[0], options: voltageChangeOptions
input name: "voltageReport", type: "enum", title: "Voltage Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "currentChange", type: "enum", title: "Current Report Value Change:", defaultValue: currentChangeOptions[0], options: currentChangeOptions
input name: "currentReport", type: "enum", title: "Current Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "currentMultChange", type: "enum", title: "Current Mult Report Value Change:", defaultValue: currentChangeOptions[0], options: currentChangeOptions
input name: "currentMultReport", type: "enum", title: "Current Mult Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "currentDivChange", type: "enum", title: "Current Div Report Value Change:", defaultValue: currentChangeOptions[0], options: currentChangeOptions
input name: "currentDivReport", type: "enum", title: "Current Div Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "energyMultChange", type: "enum", title: "Energy Mult Report Value Change:", defaultValue: energyChangeOptions[0], options: energyChangeOptions
input name: "energyMultReport", type: "enum", title: "Energy Mult Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
input name: "energyDivChange", type: "enum", title: "Energy Div Report Value Change:", defaultValue: energyChangeOptions[0], options: energyChangeOptions
input name: "energyDivReport", type: "enum", title: "Energy Div Reporting Interval:", defaultValue: timeReportOptions[0], options: timeReportOptions
}
}
def logsOff(){
log.warn "debug logging disabled..."
device.updateSetting("logEnable",[value:"false",type:"bool"])
}
def parse(String description) {
if (logEnable) log.debug "description is ${description}"
def descMap = zigbee.parseDescriptionAsMap(description)
if (logEnable) log.debug "descMap:${descMap}"
log.debug "ex1: $description"
if (description.startsWith("catchall")) return
def cluster = descMap.clusterId ?: descMap.cluster
def hexValue = descMap.value
def attrId = descMap.attrId
def encoding = descMap.encoding
def size = descMap.size
log.debug "ex2: $cluster"
switch (cluster){
case zigbeeSwitch.cluster.hexString: //switch
switch (attrId) {
case zigbeeSwitch.onOffAttr.hexString:
getSwitchResult(hexValue)
break
}
break
case zigbeeSimpleMonitoring.cluster.hexString:
//if (hexValue) log.info "power cluster: ${cluster} ${attrId} encoding: ${encoding} size: ${size} value: ${hexValue} int: ${hexStrToSignedInt(hexValue)}"
switch (attrId) {
case zigbeeSimpleMonitoring.energyAttr.hexString:
getEnergyResult(hexValue)
break
case zigbeeSimpleMonitoring.energyDayAttr.hexString:
getEnergyDayResult(hexValue)
break
case zigbeeSimpleMonitoring.powerAttr.hexString:
getPowerResult(hexValue)
break
case zigbeeSimpleMonitoring.energyMultiplierAttr.hexString:
getEnergyMultiplierResult(hexValue)
break
case zigbeeSimpleMonitoring.energyDivisorAttr.hexString:
getEnergyDivisorResult(hexValue)
break
}
break
case zigbeeElectricalMeasurement.cluster.hexString:
switch (attrId) {
case zigbeeElectricalMeasurement.voltageAttr.hexString:
getVoltageResult(hexValue)
break
case zigbeeElectricalMeasurement.powerrAttr.hexString:
getPowerrResult(hexValue)
break
case zigbeeElectricalMeasurement.currentAttr.hexString:
getCurrentResult(hexValue)
break
case zigbeeElectricalMeasurement.currentMultAttr.hexString:
getCurrentMultResult(hexValue)
break
case zigbeeElectricalMeasurement.currentDivAttr.hexString:
getCurrentDivResult(hexValue)
break
}
break
default :
if (hexValue) log.info "unknown cluster: ${cluster} ${attrId} encoding: ${encoding} size: ${size} value: ${hexValue} int: ${hexStrToSignedInt(hexValue)}"
break
}
return
}
//event methods
def getEnergyMultiplierResult(hex) {
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.energyMultiplierAttr.divisor
def name = "energy multiplier"
def unit = ""
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
// if (state.currentMultiplier && state.currentDivisor) {
// return (state.currentMultiplier / state.currentDivisor)
// } else {
// return 0.001831
// }
}
def getEnergyDivisorResult(hex) {
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.energyDivisorAttr.divisor
def name = "energy divisor"
def unit = ""
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
// if (state.currentMultiplier && state.currentDivisor) {
// return (state.currentMultiplier / state.currentDivisor)
// } else {
// return 0.001831
// }
}
def getCurrentMultResult(hex) {
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.currentMultAttr.divisor
def name = "current multiplier"
def unit = "A"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
// if (state.currentMultiplier && state.currentDivisor) {
// return (state.currentMultiplier / state.currentDivisor)
// } else {
// return 0.001831
// }
}
def getCurrentDivResult(hex) {
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.currentDivAttr.divisor
def name = "current divisor"
def unit = "A"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
// if (state.currentMultiplier && state.currentDivisor) {
// return (state.currentMultiplier / state.currentDivisor)
// } else {
// return 0.001831
// }
}
private getCurrentResult(hex){
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.currentAttr.divisor
def name = "current"
def unit = "A"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
state.current = value
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
}
private getVoltageResult(hex){
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.voltageAttr.divisor
def name = "voltage"
def unit = "V"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
}
private getPowerrResult(hex){
def value = hexStrToSignedInt(hex)
value = value / zigbeeElectricalMeasurement.powerrAttr.divisor
def name = "power"
def unit = "W"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
}
private getPowerResult(hex){
def value = hexStrToSignedInt(hex)
value = value / zigbeeSimpleMonitoring.powerAttr.divisor
def name = "power"
def unit = "W"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
}
private getEnergyDayResult(hex){
def value = hexStrToSignedInt(hex)
if (state.energyDayReset) {
state.energyDayReset = null
state.energyDayResetValue = value
}
if (state.energyDayResetValue) {
if (value < state.energyDayResetValue) {
state.energyDayResetValue = null
} else {
value -= state.energyDayResetValue
}
}
value = value / zigbeeSimpleMonitoring.energyDayAttr.divisor
def name = "energy day"
def unit = "kWh"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
}
private getEnergyResult(hex){
def value = hexStrToSignedInt(hex)
if (state.energyReset) {
state.energyReset = null
state.energyResetValue = value
}
if (state.energyResetValue) {
if (value < state.energyResetValue) {
state.energyResetValue = null
} else {
value -= state.energyResetValue
}
}
value = value / zigbeeSimpleMonitoring.energyAttr.divisor
def name = "energy"
def unit = "kWh"
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit)
setEnergyData(value)
}
private getSwitchResult(hex){
def value = hexStrToSignedInt(hex) == 1 ? "on" : "off"
def name = "switch"
def unit = ""
def descriptionText = "${device.displayName} ${name} is ${value}${unit}"
if (txtEnable) log.info "${descriptionText} [physical]"
sendEvent(name: name,value: value,descriptionText: descriptionText,unit: unit, type: "physical")
}
private setEnergyData(value){
def hoje = LocalDate.now()
state.energyYesterDay = value
state.energyToday = value
state.energyMonth = value
def name = "energyYesterDay"
def unit = "kWh"
def descriptionText = "atributo ${name} is ${state.energyYesterDay}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: state.energyYesterDay,descriptionText: descriptionText,unit: unit)
name = "energyToday"
unit = "kWh"
descriptionText = "atributo ${name} is ${state.energyToday}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: state.energyToday,descriptionText: descriptionText,unit: unit)
name = "energyMonth"
unit = "kWh"
descriptionText = "atributo ${name} is ${state.energyMonth}${unit}"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: name,value: state.energyMonth,descriptionText: descriptionText,unit: unit)
}
private getChangeValue(change) {
def changeValue
def prMatch = (change =~ /([0-9.]+) /)
if (prMatch) changeValue = prMatch[0][1]
if (changeValue.isInteger()) {
changeValue = changeValue.toInteger()
} else if(changeValue.isDouble()) {
changeValue = changeValue.toDouble()
}
return changeValue
}
private getReportValue(report) {
def reportValue
def prMatch = (report =~ /(\d+) Seconds/)
if (prMatch) reportValue = prMatch[0][1].toInteger()
prMatch = (report =~ /(\d+) Minute/)
if (prMatch) reportValue = prMatch[0][1].toInteger() * 60
prMatch = (report =~ /(\d+) Hour/)
if (prMatch) reportValue = prMatch[0][1].toInteger() * 3600
return reportValue
}
//capability and device methods
def off() {
def descriptionText = "switch is off [digital]"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: "switch",value: "off",descriptionText: descriptionText, type: "digital")
zigbee.off()
}
def on() {
def descriptionText = "switch is on [digital]"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: "switch",value: "on",descriptionText: descriptionText, type: "digital")
zigbee.on()
}
def refresh() {
log.debug "Refresh"
List cmds = []
def attrs = [zigbeeSimpleMonitoring.energyAttr.hexValue, 0x200, zigbeeSimpleMonitoring.energyDayAttr.hexValue] //, 0x200, zigbeeSimpleMonitoring.powerAttr.hexValue, 0x200, zigbeeSimpleMonitoring.unitAttr.hexValue, 0x200, zigbeeSimpleMonitoring.energyMultiplierAttr.hexValue, 0x200, zigbeeSimpleMonitoring.energyDivisorAttr.hexValue
attrs.each { it ->
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,it,[:],200)
}
def attrss = [zigbeeElectricalMeasurement.powerrAttr.hexValue, 0x200, zigbeeElectricalMeasurement.voltageAttr.hexValue, 0x200, zigbeeElectricalMeasurement.currentAttr.hexValue, 0x200, zigbeeElectricalMeasurement.currentMultAttr.hexValue, 0x200, zigbeeElectricalMeasurement.currentDivAttr.hexValue]
attrss.each { it ->
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,it,[:],200)
}
// Ask for units of measure, divisor, multiplier, and type
for (def base = 0x300; base < 0x30F; base++) {
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,base,[:],200)
}
return cmds
}
def configure() {
log.debug "Configuring Reporting and Bindings."
//runIn(1800,logsOff)
List cmds = zigbee.onOffConfig()
cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.powerAttr.hexValue,
DataType.INT24,
5,
getReportValue(powerReport),
getChangeValue(powerChange) * zigbeeSimpleMonitoring.powerAttr.divisor)
cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyAttr.hexValue,
DataType.INT8, //UINT48 ---- int24
5,
getReportValue(energyReport),
(getChangeValue(energyChange) * zigbeeSimpleMonitoring.energyAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyDayAttr.hexValue,
DataType.INT8, //UINT48 ---- uint24
5,
getReportValue(energyDayReport),
(getChangeValue(energyDayChange) * zigbeeSimpleMonitoring.energyDayAttr.divisor).toInteger())
// cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
// zigbeeSimpleMonitoring.unitAttr.hexValue,
// DataType.STRING,
// 5,
// getReportValue(unitReport),
// (getChangeValue(unitChange))
cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyMultiplierAttr.hexValue,
DataType.UINT48,
5,
getReportValue(energyMultiplierReport),
(getChangeValue(energyMultiplierChange) * zigbeeSimpleMonitoring.energyMultiplierAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyDivisorAttr.hexValue,
DataType.UINT48,
5,
getReportValue(energyDivisorReport),
(getChangeValue(energyDivisorChange) * zigbeeSimpleMonitoring.energyDivisorAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.powerrAttr.hexValue,
DataType.INT24,
5,
getReportValue(powerrReport),
(getChangeValue(powerrChange) * zigbeeElectricalMeasurement.powerrAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.voltageAttr.hexValue,
DataType.INT24,
5,
getReportValue(voltageReport),
(getChangeValue(voltageChange) * zigbeeElectricalMeasurement.voltageAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentAttr.hexValue,
DataType.INT24,
5,
getReportValue(currentReport),
(getChangeValue(currentChange) * zigbeeElectricalMeasurement.currentAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentMultAttr.hexValue,
DataType.INT24,
5,
getReportValue(currentMultReport),
(getChangeValue(currentChange) * zigbeeElectricalMeasurement.currentMultAttr.divisor).toInteger())
cmds = cmds + zigbee.configureReporting(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentDivAttr.hexValue,
DataType.INT24,
5,
getReportValue(currentDivReport),
(getChangeValue(currentChange) * zigbeeElectricalMeasurement.currentDivAttr.divisor).toInteger())
cmds = cmds + refresh()
if (logEnabled) log.info "cmds:${cmds}"
return cmds
}
def getReadings() {
List cmds = []
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.powerAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyDayAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyMultiplierAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeSimpleMonitoring.cluster.hexValue,
zigbeeSimpleMonitoring.energyDivisorAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.powerrAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.voltageAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentMultAttr.hexValue,
[:],20)
cmds += zigbee.readAttribute(zigbeeElectricalMeasurement.cluster.hexValue,
zigbeeElectricalMeasurement.currentDivAttr.hexValue,
[:],20)
return cmds
}
def updated() {
log.trace "Updated()"
log.trace "powerChangeValue: " + getChangeValue(powerChange)
log.trace "powerReportvalue: " + getReportValue(powerReport)
log.trace "energyChangeValue: " + getChangeValue(energyChange)
log.trace "energyReportvalue: " + getReportValue(energyReport)
log.trace "energyDayChangeValue: " + getChangeValue(energyDayChange)
log.trace "energyDayReportvalue: " + getReportValue(energyDayReport)
log.trace "energyMultiplierChangeValue: " + getChangeValue(energyMultiplierChange)
log.trace "energyDivisorReportvalue: " + getReportValue(energyDivisorReport)
log.trace "powerrChangeValue: " + getChangeValue(powerrChange)
log.trace "powerrReportvalue: " + getReportValue(powerrReport)
log.trace "voltageChangeValue: " + getChangeValue(voltageChange)
log.trace "voltageReportvalue: " + getReportValue(voltageReport)
log.trace "currentChangeValue: " + getChangeValue(currentChange)
log.trace "currentReportvalue: " + getReportValue(currentReport)
log.trace "currentMultChangeValue: " + getChangeValue(currentMultChange)
log.trace "currentDivReportvalue: " + getReportValue(currentDivReport)
log.warn "debug logging is: ${logEnable == true}"
log.warn "description logging is: ${txtEnable == true}"
if (logEnable) runIn(1800,logsOff)
return configure()
}
def resetEnergy() {
state.energyReset = true
return getReadings()
}