-
Notifications
You must be signed in to change notification settings - Fork 2
/
intermatic-pe653-pool-control-system.groovy
2336 lines (2156 loc) · 101 KB
/
intermatic-pe653-pool-control-system.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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Intermatic PE653 Pool Control System
*
* Original Copyright 2014 bigpunk6
* Updated 2016 - 2020 KeithR26
* Updated 2018 - 2019 Tooluser
*
* 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.
*
* This DTH is a "Composite Device Type Handler" which supports multiple "Child" devices that appear in
* the "Things" list and can be used by SmartApps to control the 5 switches, Pool/Spa mode and 4 VSP speeds.
* This requires a second DTH be installed: erocm123 / Switch Child Device
*
* Don't use SamrtThings Multi-channel (deprecated) or Cooper Lee's code (vTile_ms, ms_w_vts). These are incompatible
* with the Composite DTH architecture.
*
* This code was primarily written by bigpunk6 and KeithR26.
*
* To convert to Hubitat:
* 1. Replace All: "physicalgraph<period>" with "hubitat<period>"
* 2. Change "definition" line from SmartThings to Hubitat.
*
* Version History
* Ver Date Author Changes
* 1.00 06/15/2016 bigpunk6 Latest version from the original author
* 2.00 07/14/2016 KeithR26 Updates to make this work with Intermatic firmware v3.4
* Added Pool/Spa mode and initial VSP support
* 2.01 08/10/2016 KeithR26 Major UI redesign
* Added 4 switches to set VSP speeds and off
* Added 4 "Multi-channel" endpoints for ST VSP control
* Added configurable Z-Wave delay
* Added PE653 configuration diagnostics in Debug level = High
* Added Version Info in IDE and logs
* Allow changing icon
* 2.02 04/26/2017 KeithR26 Fix Thermostat set for v3.4 firmware (force scale = 0)
* Prototype Pool Light Color Control
* Implement simple "Macros"
* 2.03 05/01/2017 KeithR26 Refresh water temp when UI temp is tapped
* 2.04 05/07/2017 KeithR26 Allow negative temperature offsets. Limit offets to +/- 5 (max supported by PE653)
* 2.05 05/13/2017 KeithR26 Debug version for Android. Never committed to master
* 2.06 05/13/2017 KeithR26 Update to fix Temperature display on Android
* 3.00 07/05/2018 KeithR26 Change to "Composite" DTH since ST deprecated the Multi-channel SmartApp
* Improves VSP integration. No more schedules.
* Reorganized UI. Display Air temp, Heater on/off and Clock.
* Minor adjustments for Hubitat compatibility.
* Remove defaults to fix Android config issues.
* 3.01 07/06/2018 KeithR26 Added second Air Temperature. Now displays both Freeze and Solar temps.
* 3.02 07/07/2018 KeithR26 Avoid sending events and warnings if no VSP
* 3.03 07/15/2018 KeithR26 More minor adjustments to improve Hubitat compatibility
* 3.04 07/15/2018 KeithR26 Added setSchedule, resetSchedule, getSchedules, and setVSPSpeeds commands
* Added Schedule events
* 07/22/2018 KeithR26 Due to different Intermatic firmware sub-versions of v3.4, alternate Setpoint "scale" if SetPointSet is ignored ("learn")
* Fix negative air and solar temperature display
* 08/09/2018 KeithR26 Fixes to getSchedules.
* Fix QuickGetWaterTemp
* Fix update of "Set Mode" labels on the UI
* 3.05 08/19/2018 KeithR26 Finish off Schedule functions
* Possible fix to set Clock
* Fix Light Color slider
* 3.06 08/30/2018 KeithR26 Make temperature events visible
* Suppress redundant events
* 3.07 04/10/2018 KeithR26 Hubitat fixes
* 3.1.0 12/01/2018 Tooluser Semantic versioning and further adaptation to the Hubitat system
* 3.1.4a 06/19/2019 Tooluser Standardize logging, Null protection for tempoffsets
* 3.2.0 04/21/2019 KeithR26 More Hubitat fixes
* 3.2.1 10/23/2019 KeithR26 Added dual Thermostat child devices
* 4.0.0 05/05/2020 KeithR26 Official Release with Child Thermostats and merged log code
* 4.0.1 06/06/2020 KeithR26 Fixed update of Version string (was showing old version)
* Added P5043 expansion detection
* Improved P4043/P4243 expnsion handling of Pool/Spa switch and Heater state.
* Add refresh() to poll() every POLL_REFERSH_FREQ minutes
* Added more specific log options
* 4.0.2 07/01/2020 KeithR26 Improve shared control by the DTH AND the PE953 remote
* Implemented Thermostat child device on ST
* Fixed command sending from updated()
* Add support for Intermatic firmware v3.1 (old - most users on v3.4)
*/
def getVERSION () {"Ver 4.0.2"} // Keep track of handler version
metadata {
definition (name: "Intermatic Pool Control System - Hubitat", author: "KeithR26", namespace: "KeithR26") {
capability "Actuator"
capability "Switch"
capability "Polling"
capability "Configuration"
capability "Refresh"
capability "Temperature Measurement"
capability "Sensor"
attribute "clock", "string"
attribute "temperature", "string"
attribute "airTempFreeze", "string"
attribute "airTempSolar","string"
attribute "heater", "string"
attribute "poolSetpoint", "string"
attribute "spaSetpoint", "string"
attribute "poolSpaMode", "string"
attribute "lightColor", "string"
attribute "ccVersions", "string"
attribute "VersionInfo", "string"
attribute "ManufacturerInfo", "string"
attribute "debugLevel", "string"
attribute "switch1", "string"
attribute "switch2", "string"
attribute "switch3", "string"
attribute "switch4", "string"
attribute "switch5", "string"
attribute "swVSP1", "string"
attribute "swVSP2", "string"
attribute "swVSP3", "string"
attribute "swVSP4", "string"
attribute "schedules", "JSON_OBJECT"
attribute "lastScheduleChg", "string"
attribute "VSPSpeeds", "string"
command "poll"
command "quickSetPool", ["number"]
command "quickSetSpa", ["number"]
command "quickGetWaterTemp"
command "quickGetWaterTempOld"
command "quickGetTestCmds"
command "setPoolMode"
command "setSpaMode"
command "togglePoolSpaMode"
command "childOn"
command "childOff"
command "childSetHeatingSetpoint"
command "on1"
command "off1"
command "on2"
command "off2"
command "on3"
command "off3"
command "on4"
command "off4"
command "on5"
command "off5"
command "recreateChildren"
command "setVSPSpeed", ["number"]
command "setVSPSpeed0"
command "setVSPSpeed1"
command "setVSPSpeed2"
command "setVSPSpeed3"
command "setVSPSpeed4"
command "setMode1"
command "setMode2"
command "setMode3"
command "setMode4"
command "setLightColor", ["number"]
command "setColor"
command "setClock"
command "getSchedules", ["number"]
command "setSchedule", ["number","number","number","number","number","number"]
command "resetSchedule", ["number","number"]
command "setVSPSpeeds"
command "insertLogTrace"
command "executeArbitraryCommand", ["string"]
command "updated"
fingerprint deviceId: "0x1001", inClusters: "0x91,0x73,0x72,0x86,0x81,0x60,0x70,0x85,0x25,0x27,0x43,0x31", outClusters: "0x82"
}
preferences {
input "operationMode1", "enum", title: "Booster/Cleaner Pump",
options:[[1:"No"],
[2:"Uses Circuit-1"],
[3:"Variable Speed pump Speed-1"],
[4:"Variable Speed pump Speed-2"],
[5:"Variable Speed pump Speed-3"],
[6:"Variable Speed pump Speed-4"]]
input "operationMode2", "enum", title: "Pump Type",
options:[[0:"1 Speed Pump without Booster/Cleaner"],
[1:"1 Speed Pump with Booster/Cleaner"],
[2:"2 Speed Pump without Booster/Cleaner"],
[3:"2 Speed Pump with Booster/Cleaner"],
[4:"Variable Speed Pump without Booster/Cleaner"],
[5:"Variable Speed Pump with Booster/Cleaner"],
[6:"Reserved 6"],
[7:"Reserved 7"]]
input "poolSpa1", "enum", title: "Pool or Spa",
options:[[0:"Pool"],
[1:"Spa"],
[2:"Both"]]
input "fireman", "enum", title: "Fireman Timeout",
options:[["255":"No heater installed"],
["0":"No cool down period"],
["1":"1 minute"],
["2":"2 minute"],
["3":"3 minute"],
["4":"4 minute"],
["5":"5 minute"],
["6":"6 minute"],
["7":"7 minute"],
["8":"8 minute"],
["9":"9 minute"],
["10":"10 minute"],
["11":"11 minute"],
["12":"12 minute"],
["13":"13 minute"],
["14":"14 minute"],
["15":"15 minute"]]
input "tempOffsetwater", "number", title: "Water temperature offset", range: "-5..5", defaultValue: 0, required: true
input "tempOffsetair", "number",
title: "Air temperature offset - Sets the Offset of the air temperature for the add-on Thermometer in degrees Fahrenheit -5F to +5F", range: "-5..5", defaultValue: 0, required: true
input "debugLevel", "enum", title: "Debug Level", multiple: "true",
options:[[0:"Off"],
[1:"Low - normal"],
[2:"Command formatting"],
[3:"Event suppression"],
[4:"Manufacturers msgs"],
[5:"Child Devices"]], defaultvalue: 1
input "ZWdelay", "number",
title: "Delay between Z-Wave commands sent (milliseconds). Suggest 1000.", defaultValue: 1000, required: true
//Mode 1
input "M1Label", "text", title: "M1: Display Name:", defaultValue: ""
input "M1Sw1", "enum", title: "M1: Circuit 1 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M1Sw2", "enum", title: "M1: Circuit 2 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M1Sw3", "enum", title: "M1: Circuit 3 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M1Sw4", "enum", title: "M1: Circuit 4 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M1Sw5", "enum", title: "M1: Circuit 5 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M1Mode", "enum", title: "M1: Mode to change to:", defaultValue: 0,
options:[[0:"No change"],
[1:"Pool"],
[2:"Pool & Set Temperature"],
[3:"Spa"],
[4:"Spa & Set Temperature"]]
input "M1Temp", "number", title: "M1: Set Temperature to:", range: "40..104", defaultValue: 40
input "M1VSP", "enum", title: "M1: Set VSP Speed to:", defaultValue: 0,
options:[[5:"No change"],
[1:"Speed 1"],
[2:"Speed 2"],
[3:"Speed 3"],
[4:"Speed 4"],
[0:"Turn off"]]
//Mode 2
input "M2Label", "text", title: "M2: Display Name:", defaultValue: ""
input "M2Sw1", "enum", title: "M2: Circuit 1 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[ 2:"Off"]]
input "M2Sw2", "enum", title: "M2: Circuit 2 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M2Sw3", "enum", title: "M2: Circuit 3 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M2Sw4", "enum", title: "M2: Circuit 4 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M2Sw5", "enum", title: "M2: Circuit 5 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M2Mode", "enum", title: "M2: Mode to change to:", defaultValue: 0,
options:[[0:"No change"],
[1:"Pool"],
[2:"Pool & Set Temperature"],
[3:"Spa"],
[4:"Spa & Set Temperature"]]
input "M2Temp", "number", title: "M2: Set Temperature to:", range: "40..104", defaultValue: 40
input "M2VSP", "enum", title: "M2: Set VSP Speed to:", defaultValue: 0,
options:[[5:"No change"],
[1:"Speed 1"],
[2:"Speed 2"],
[3:"Speed 3"],
[4:"Speed 4"],
[0:"Turn off"]]
//Mode 3
input "M3Label", "text", title: "M3: Display Name:", defaultValue: ""
input "M3Sw1", "enum", title: "M3: Circuit 1 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M3Sw2", "enum", title: "M3: Circuit 2 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M3Sw3", "enum", title: "M3: Circuit 3 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M3Sw4", "enum", title: "M3: Circuit 4 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M3Sw5", "enum", title: "M3: Circuit 5 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M3Mode", "enum", title: "M3: Mode to change to:", defaultValue: 0,
options:[[0:"No change"],
[1:"Pool"],
[2:"Pool & Set Temperature"],
[3:"Spa"],
[4:"Spa & Set Temperature"]]
input "M3Temp", "number", title: "M3: Set Temperature to:", range: "40..104", defaultValue: 40
input "M3VSP", "enum", title: "M3: Set VSP Speed to:", defaultValue: 0,
options:[[5:"No change"],
[1:"Speed 1"],
[2:"Speed 2"],
[3:"Speed 3"],
[4:"Speed 4"],
[0:"Turn off"]]
//Mode 4
input "M4Label", "text", title: "M4: Display Name:", defaultValue: ""
input "M4Sw1", "enum", title: "M4: Circuit 1 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M4Sw2", "enum", title: "M4: Circuit 2 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M4Sw3", "enum", title: "M4: Circuit 3 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M4Sw4", "enum", title: "M4: Circuit 4 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M4Sw5", "enum", title: "M4: Circuit 5 action:", defaultValue: 0,
options:[[0:"No Change"],
[1:"On"],
[2:"Off"]]
input "M4Mode", "enum", title: "M4: Mode to change to:", defaultValue: 0,
options:[[0:"No change"],
[1:"Pool"],
[2:"Pool & Set Temperature"],
[3:"Spa"],
[4:"Spa & Set Temperature"]]
input "M4Temp", "number", title: "M4: Set Temperature to:", range: "40..104", defaultValue: 40
input "M4VSP", "enum", title: "M4: Set VSP Speed to:", defaultValue: 0,
options:[[5:"No change"],
[1:"Speed 1"],
[2:"Speed 2"],
[3:"Speed 3"],
[4:"Speed 4"],
[0:"Turn off"]]
input "C1ColorEnabled", "enum", title: "Circuit 1 Color Light Enable:", defaultValue: 0,
options:[[0:"off"],
[1:"On"]]
input "C2ColorEnabled", "enum", title: "Circuit 2 Color Light Enable:", defaultValue: 0,
options:[[0:"off"],
[1:"On"]]
input "C3ColorEnabled", "enum", title: "Circuit 3 Color Light Enable:", defaultValue: 0,
options:[[0:"off"],
[1:"On"]]
input "C4ColorEnabled", "enum", title: "Circuit 4 Color Light Enable:", defaultValue: 0,
options:[[0:"off"],
[1:"On"]]
input "C5ColorEnabled", "enum", title: "Circuit 5 Color Light Enable:", defaultValue: 0,
options:[[0:"off"],
[1:"On"]]
}
// tile definitions
tiles(scale: 2) {
valueTile("mainTile", "device.temperature", width: 2, height: 2, inactiveLabel: true ) {
state "temperature", label:'${currentValue}°', action: "quickGetWaterTemp",icon: "st.Health & Wellness.health2",
backgroundColors:[
[value: 32, color: "#153591"],
[value: 54, color: "#1e9cbb"],
[value: 64, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 90, color: "#f1d801"],
[value: 98, color: "#d04e00"],
[value: 110, color: "#bc2323"]
]
}
valueTile("temperatureTile", "device.temperature", width: 2, height: 2, inactiveLabel: true ) {
state "temperature", label:'${currentValue}°', action: "quickGetWaterTemp",
backgroundColors:[
[value: 32, color: "#153591"],
[value: 54, color: "#1e9cbb"],
[value: 64, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 90, color: "#f1d801"],
[value: 98, color: "#d04e00"],
[value: 110, color: "#bc2323"]
]
}
valueTile("airTempFTile", "device.airTempFreeze", width: 1, height: 1, inactiveLabel: true ) {
state "airTemp", label:'${currentValue}°',
backgroundColors:[
[value: 0, color: "#ffffff"],
[value: 32, color: "#153591"],
[value: 54, color: "#1e9cbb"],
[value: 64, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 90, color: "#f1d801"],
[value: 98, color: "#d04e00"],
[value: 110, color: "#bc2323"]
]
}
valueTile("airTempSTile", "device.airTempSolar", width: 1, height: 1, inactiveLabel: true ) {
state "airTemp", label:'${currentValue}°',
backgroundColors:[
[value: 0, color: "#ffffff"],
[value: 32, color: "#153591"],
[value: 54, color: "#1e9cbb"],
[value: 64, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 90, color: "#f1d801"],
[value: 98, color: "#d04e00"],
[value: 110, color: "#bc2323"]
]
}
valueTile("airTempLabel", "device.airTempLabel", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
state "airTemp", label:' AIR: Frz/Sol', action:"quickGetTestCmds", backgroundColor:"#ffffff"
}
controlTile("poolSliderControl", "device.poolSetpoint", "slider", width: 2, height: 1, inactiveLabel: false, range:"(39..104)") {
state "PoolSetpoint", action:"quickSetPool", backgroundColor:"#d04e00"
}
valueTile("poolSetpoint", "device.poolSetpoint", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
state "pool", label:' POOL:', backgroundColor:"#ffffff"
}
controlTile("spaSliderControl", "device.spaSetpoint", "slider", width: 2, height: 1, inactiveLabel: false, range:"(39..104)") {
state "SpaSetpoint", action:"quickSetSpa", backgroundColor: "#1e9cbb"
}
valueTile("spaSetpoint", "device.spaSetpoint", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
state "spa", label:' SPA:', backgroundColor:"#ffffff"
}
controlTile("lightColorSliderControl", "device.lightColor", "slider", width: 2, height: 1, inactiveLabel: false, range:"(1..14)") {
state "color", action:"setLightColor", backgroundColor:"#d04e00"
}
valueTile("lightColor", "device.lightColorBtn", width: 1, height: 1, inactiveLabel: true, decoration: "flat") {
state "color", action:"setColor", label:'COLOR:', backgroundColor:"#ffffff"
}
standardTile("poolSpaMode", "device.poolSpaMode", width: 2, height: 2, decoration: "flat") {
state "on", label: "", action: "setPoolMode", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/spa.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "", action: "setSpaMode", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/Pool.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label: 'changing', action: "setPoolMode", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/spa.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label: 'changing', action: "setSpaMode", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/Pool.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "disabled", label:'', icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/all-white.png", backgroundColor: "#ffffff"
}
standardTile("switch1", "device.switch1", width: 1, height: 1, decoration: "flat") {
state "on", label: "on", action: "off1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw1-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "off", action: "on1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw1-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label:'Turning on', action: "off1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw1-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "on1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw1-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
}
standardTile("switch2", "device.switch2", width: 1, height: 1, decoration: "flat") {
state "on", label: "on", action: "off2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw2-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "off", action: "on2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw2-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label:'Turning on', action: "off2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw2-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "on2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw2-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
}
standardTile("switch3", "device.switch3", width: 1, height: 1, decoration: "flat") {
state "on", label: "on", action: "off3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw3-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "off", action: "on3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw3-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label:'Turning on', action: "off3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw3-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "on3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw3-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
}
standardTile("switch4", "device.switch4", width: 1, height: 1, decoration: "flat") {
state "on", label: "on", action: "off4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw4-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "off", action: "on4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw4-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label:'Turning on', action: "off4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw4-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "on4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw4-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
}
standardTile("switch5", "device.switch5", width: 1, height: 1, decoration: "flat") {
state "on", label: "on", action: "off5", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw5-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "off", label: "off", action: "on5", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw5-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "turningOn", label:'Turning on', action: "off5", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw5-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "on5", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/sw5-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
}
standardTile("swVSP1", "device.swVSP1", width: 1, height: 1, decoration: "flat") {
state "off", label: "off", action: "setVSPSpeed1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp1-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "on", label: "on", action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp1-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOn", label:'Turning on', action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp1-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "setVSPSpeed1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp1-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "disabled", label:'', icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/all-white.png",backgroundColor: "#ffffff"
}
standardTile("swVSP2", "device.swVSP2", width: 1, height: 1, decoration: "flat") {
state "off", label: "off", action: "setVSPSpeed2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp2-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "on", label: "on", action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp2-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOn", label:'Turning on', action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp2-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "setVSPSpeed2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp2-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "disabled", label:'', icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/all-white.png",backgroundColor: "#ffffff"
}
standardTile("swVSP3", "device.swVSP3", width: 1, height: 1, decoration: "flat") {
state "off", label: "off", action: "setVSPSpeed3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp3-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "on", label: "on", action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp3-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOn", label:'Turning on', action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp3-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "setVSPSpeed3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp3-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "disabled", label:'', icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/all-white.png",backgroundColor: "#ffffff"
}
standardTile("swVSP4", "device.swVSP4", width: 1, height: 1, decoration: "flat") {
state "off", label: "off", action: "setVSPSpeed4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp4-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "on", label: "on", action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp4-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOn", label:'Turning on', action: "setVSPSpeed0", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp4-on.png", backgroundColor: "#79b821", nextState: "turningOff"
state "turningOff", label:'Turning off', action: "setVSPSpeed4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/vsp4-off.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "disabled", label:'', icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/all-white.png",backgroundColor: "#ffffff"
}
standardTile("swM1", "device.swM1", width: 1, height: 1, decoration: "flat") {
state "disabled", label:'', action: "setMode1", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/M1-off.png",backgroundColor: "#ffffff", nextState: "disabled"
}
standardTile("swM2", "device.swM2", width: 1, height: 1, decoration: "flat") {
state "disabled", label:'', action: "setMode2", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/M2-off.png",backgroundColor: "#ffffff", nextState: "disabled"
}
standardTile("swM3", "device.swM3", width: 1, height: 1, decoration: "flat") {
state "disabled", label:'', action: "setMode3", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/M3-off.png",backgroundColor: "#ffffff", nextState: "disabled"
}
standardTile("swM4", "device.swM4", width: 1, height: 1, decoration: "flat") {
state "disabled", label:'', action: "setMode4", icon: "https://raw.githubusercontent.com/KeithR26/Intermatic-PE653/master/M4-off.png", backgroundColor:"#ffffff", nextState: "disabled"
}
valueTile("M1Name", "device.M1Name", width: 2, height: 1, inactiveLabel: false, decoration: "flat") {
state "M1Name", label:'${currentValue}', backgroundColor:"#ffffff", action: "setMode1"
}
valueTile("M2Name", "device.M2Name", width: 2, height: 1, inactiveLabel: false, decoration: "flat") {
state "M2Name", label:'${currentValue}', backgroundColor:"#ffffff", action: "setMode2"
}
valueTile("M3Name", "device.M3Name", width: 2, height: 1, inactiveLabel: false, decoration: "flat") {
state "M3Name", label:'${currentValue}', backgroundColor:"#ffffff", action: "setMode3"
}
valueTile("M4Name", "device.M4Name", width: 2, height: 1, inactiveLabel: false, decoration: "flat") {
state "M4Name", label:'${currentValue}', backgroundColor:"#ffffff", action: "setMode4"
}
standardTile("blank1", "device.blank", width: 2, height: 1, decoration: "flat") {
state "on", icon: "st.Health & Wellness.health2", backgroundColor: "#ffffff"
}
standardTile("refresh", "device.switch", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
// state "default", label:'', action:"updated", icon:"st.secondary.refresh"
}
standardTile("insertLogTrace", "something", width: 6, height: 1, inactiveLabel: false, decoration: "flat") {
state "default", label:"Insert Trace in Log", action: "insertLogTrace"
}
valueTile("clock", "device.clock", width: 2, height: 1, inactiveLabel: false, decoration: "flat") {
state "clockName", label:'${currentValue}', backgroundColor:"#ffffff", action: "setClock"
}
valueTile("heaterLabel", "device.heaterLabel", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
state "airTemp", label:' HEAT:', backgroundColor:"#ffffff"
}
standardTile("heaterTile", "device.heater", width: 2, height: 1, canChangeIcon: true) {
state "off", label: "heater off", icon: "st.Health & Wellness.health2", backgroundColor: "#ffffff"
state "on", label: "*HEATING*", icon: "st.Health & Wellness.health2", backgroundColor: "#bc2323"
}
// standardTile("configure", "device.configure", width: 1, height: 1, inactiveLabel: false, decoration: "flat") {
// state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
// }
standardTile("blank3", "device.blank3", width: 1, height: 1, decoration: "flat") {
state "on", label: "", icon: "st.Health & Wellness.health2", backgroundColor: "#ffffff"
}
main "mainTile"
details([
"blank3",
"switch1","switch2","switch3","switch4","switch5",
"poolSpaMode",
"temperatureTile",
"swVSP1","swVSP2","swVSP3","swVSP4",
"poolSetpoint", "poolSliderControl",
"spaSetpoint", "spaSliderControl",
"swM1", "M1Name",
"swM2", "M2Name",
"swM3", "M3Name",
"swM4", "M4Name",
"lightColor","lightColorSliderControl",
"heaterLabel", "heaterTile",
"airTempLabel", "airTempFTile", "airTempSTile",
"refresh",
"clock",
// "blank1",
// "configure",
])
}
}
// Constants for PE653 configuration parameter locations
def getST_PLATFORM() {"hubitat.".startsWith("physical")}// Used in 1 place that needs different code by platform: ST vs HE
// The above line is modified by the "replace All" mentioned at line 27
def getDELAY () {ZWdelay} // How long to delay between commands to device (configured)
def getMIN_DELAY () {"800"} // Minimum delay between commands to device (configured)
def getPOLL_REFRESH_FREQ () {10} // Every X minutes (roughly) refresh setpoints and config from PE6553
int getDBG_NEVER () {0} // log line kept around for future use but never actually logged
int getDBG_LOW () {1} // Baseline logging that you can always leave on (minimal)
int getDBG_CMDS () {2} // Shows how Lists of Commands/Events are processed prior to passing to the Hub
int getDBG_EVNTS () {3} // Shows why/when events are sent versus suppressed
int getDBG_MANF () {4} // Focus on Manufacturer Proprietary message processing
int getDBG_CHILD () {5} // Focus on child device creation and message processing
int getDBG_ALWAYS () {9} // Always logged regardless of debugLevel (Warnings/Errors)
def getSWITCH_SCHED_PARAM (int sw, int sch) { (4 + (sw-1)*3 + (sch-1)) } // Configuration schedule for switch 1-5
def getVSP_RPM_SCHED_PARAM (int sp) { (32 + (sp-1))} // Configuration schedule for VSP RPM Speeds 1-4
def getVSP_RPMMAX_SCHED_PARAM () { (49) } // VSP RPM Max speed Schedule 0x31
def getPOOL_SPA_SCHED_PARAM (int sch) { 19 + (sch-1) } // Pool/Spa mode Schedule 1-3 - 0x13
def getPOOL_SPA_CONFIG () { 22 } // Pool/Spa mode Mode - 0x16
def getVSP_SCHED_PARAM (int sp, int sch) { (36 + (sp-1)*3 + (sch-1)) } // VSP Speed 1-4 Schedule 1-3 - 0x24
def getFIRMWARE_VERSION () { state.firmwareVersion ?: "0.0" }
//def getP5043_EXPANSION () { state.expansionVersion=="3.4" } // This method name doesn't seem to work (6/21/20)
def getEXPANSION_5043 () { state.expansionVersion=="3.4" }
def getPOOL_SPA_CHAN_P5043 () { 39 } // Pool/Spa channel - 0x27 for P5043 expansion
def getPOOL_SPA_CHAN () { EXPANSION_5043 ? 39 : 4 } // Pool/Spa channel - 0x27 if P5043 otherwise 0x04 (Switch 4)
def getPOOL_SPA_EP () { 6 } // Pool/Spa endpoint - 6
def getVSP_SPEED (int sched) { ((sched - 35) / 3) } // Convert from sched to speed
def getVSP_CHAN_NO (int spd) { (16 + (spd - 1)) } // VSP Speed 1 Channel - 0x10 - 0x13
def getVSP_EP (int spd) { (6 + spd) } // VSP Endpoint 7 - 10
def getVSP_SPEED_FROM_CHAN (int chan) { ((chan - 16) + 1) } // Convert from channel to speed - 0x10
def getVSP_ENABLED () { (operationMode2 >= "4") ? 1 : 0 } // True if a Variable Speed Pump Configured
def getHAS_HEATER () {fireman.toInteger() != 255} // True if Heater equiped
def getPOOL_SPA_COMBO () { (poolSpa1 == "2") ? 1 : 0 } // True if both Pool and Spa
def getPOOL_TEMPERATURE_EP () { 11 } // Child Temperature Endpoint for Pool 11
def getSPA_TEMPERATURE_EP () { 12 } // Child Temperature Endpoint for Spa 12
def getPOOL_SETPOINT_EP () { 13 } // Child Setpoint Endpoint for Pool 13
def getSPA_SETPOINT_EP () { 14 } // Child Setpoint Endpoint for Spa 14
def getPOOL_THERMOSTATMODE_EP () { 15 } // Child Mode Endpoint for Pool 15
def getSPA_THERMOSTATMODE_EP () { 16 } // Child Mode Endpoint for Spa 16
def getPOOL_THERMOSTATOPERATINGSTATE_EP () { 17 } // Child State Endpoint for Pool 17
def getSPA_THERMOSTATOPERATINGSTATE_EP () { 18 } // Child State Endpoint for Spa 18
def getPOOL_SETPOINTTYPE () {1} // Setpoint Type 1 is for the Pool
def getSPA_SETPOINTTYPE () {7} // Setpoint Type 7 is for the Spa
def getLOCAL_ATTR_NAME (int id) {
def swNames = ["switch1","switch2","switch3","switch4","switch5","poolSpaMode","swVSP1","swVSP2","swVSP3","swVSP4","temperature","temperature", "poolSetpoint", "spaSetpoint", null, null, "heater", "heater"]
return swNames[id - 1]
}
def getEXT_ATTR_NAME (int id) {
def swAttrs = ["switch", "switch", "switch", "switch", "switch", "switch", "switch","switch","switch","switch","temperature","temperature", "heatingSetpoint", "heatingSetpoint", "thermostatMode", "thermostatMode", "thermostatOperatingState", "thermostatOperatingState"]
return swAttrs[id - 1]
}
def getEXT_EP_NUM (int id) {
def swEPs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12, 11, 12, 11, 12]
return swEPs[id - 1]
}
def getSCHED_PARAM (int ep, int sch) {
if (ep >= 1 && ep <= 5) {return getSWITCH_SCHED_PARAM(ep, sch)}
if (ep == 6) {return getPOOL_SPA_SCHED_PARAM(sch)}
if (ep >= 7 && ep <= 10) {return getVSP_SCHED_PARAM(ep-6, sch)}
return 0
}
def getEP_FROM_SCHED_PARM (int paramNum) {
if (paramNum >= getSCHED_PARAM (1, 1) && paramNum <= getSCHED_PARAM (5, 3)) {return ((paramNum - getSCHED_PARAM(1,1)).intdiv(3) + 1)}
if (paramNum >= getSCHED_PARAM (6, 1) && paramNum <= getSCHED_PARAM (6, 3)) {return 6}
if (paramNum >= getSCHED_PARAM (7, 1) && paramNum <= getSCHED_PARAM (10, 3)) {return ((paramNum - getSCHED_PARAM(7,1)).intdiv(3) + 1 + 6)}
return 0
}
// Return the list supported command classes by PE653. The following are the versions for firmware v3.4
// ccVersions: {"20":1,"25":1,"27":1,"31":1,"43":1,"60":2,"70":1,"72":1,"73":1,"81":1,"85":1,"86":1,"91":1}
def getSupportedCmdClasses () {[
0x20, // Basic
0x25, // Switch Binary
0x27, // Switch All
0x31, // Sensor Multilevel
0x43, // Thermostat setpoint
0x60, // Multi Instance
0x70, // Configuration
0x72, // Manufacturer Specific
0x73, // Powerlevel
0x81, // Clock
0x85, // Association
0x86, // Version
0x91 // Manufacturer Proprietary
]
}
// Main entry point for messages from the device
def parse(String description) {
log("TRACE", DBG_NEVER, ">>>>> Incoming: [$description]")
def result = null
def command = null
def cmd = null
def payloadStr = ""
byte[] payload = []
if (description.startsWith("Err")) {
log("WARN", DBG_ALWAYS, "Error in Parse")
result = createEvent(descriptionText:description, isStateChange:true)
} else {
try {
def command1 = description.split('command:')[1]
command = command1.split(',')[0]
payloadStr = description.split('payload:')[1]
} catch (e) {
log("ERROR", DBG_ALWAYS, "..... Exception in Parse() ${cmd} - description:${description} exception ${e}")
}
// log("DEBUG", DBG_NEVER, "command: ${command} payloadStr: ${payloadStr}")
if (command.contains("9100")) {
// new sample: [zw device: 04, command: 9100, payload: 05 40 02 02 84 00 10 02 03 00 02 01 4F 00 50 08 38 15 00 00 01 03 04 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 , isMulticast: false]
try {
payloadStr = payloadStr.split(',')[0] // Remove any unexpected attributs following payload:
payload = payloadStr.replace(" ","").decodeHex()
} catch (e) {
log("ERROR", DBG_ALWAYS, "..... Exception in Parse() - decodeHex() ${cmd} - description:${description} exception ${e}")
}
result = zwaveEventManufacturerProprietary(payload, payloadStr)
} else {
try {
// cmd = zwave.parse(description, [0x20: 1, 0x25:1, 0x27:1, 0x31:1, 0x43:1, 0x60:3, 0x70:2, 0x72:1, 0x81:1, 0x85:2, 0x86: 1, 0x73:1, 0x91:1])
cmd = zwave.parse(description, [0x20: 1, 0x25:1, 0x27:1, 0x31:1, 0x43:1, 0x60:1, 0x70:2, 0x72:1, 0x81:1, 0x85:2, 0x86: 1, 0x73:1, 0x91:1])
} catch (e) {
log("WARN", DBG_ALWAYS, ">>>>> Exception in zwave.parse() ${cmd} - raw[${description}] exceptioon ${e}")
}
if (cmd) {
log("DEBUG", DBG_LOW, ">>>>> ${cmd} - raw[$description]")
result = zwaveEvent(cmd)
} else {
log("WARN", DBG_ALWAYS, ">>>>> Parse() parsed to NULL: description:$description")
return null
}
}
}
prepareResponseAndLog(result)
}
//Reports
def zwaveEvent(hubitat.zwave.commands.versionv1.VersionReport cmd) {
state.VersionInfo = "Versions: Firmware v${cmd.applicationVersion}.${cmd.applicationSubVersion} DTH: ${VERSION} zWaveLibraryType: ${cmd.zWaveLibraryType} zWaveProtocol: v${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}"
createEvent(name: "VersionInfo", value: state.VersionInfo, displayed: true, descriptionText: state.VersionInfo)
}
def zwaveEvent(hubitat.zwave.commands.versionv1.VersionCommandClassReport cmd) {
if (cmd.commandClassVersion) {
def cls = String.format("%02X", cmd.requestedCommandClass)
state.ccVersions[cls] = cmd.commandClassVersion
createEvent(name: "ccVersions", value: util.toJson(state.ccVersions), displayed: false, descriptionText:"")
} else {
[]
}
}
def zwaveEvent(hubitat.zwave.commands.clockv1.ClockReport cmd) {
def time1 = ""
time1 = "${String.format("%02d",cmd.hour)}:${String.format("%02d",cmd.minute)}"
log("DEBUG", "----- ClockReport: from PE653=${time1}")
createEvent(name: "clock", value: "${time1}", displayed: false, descriptionText: "PE653 Clock: ${time1}")
}
def zwaveEvent(hubitat.zwave.commands.thermostatsetpointv1.ThermostatSetpointSupportedReport cmd) {
log("DEBUG", "----- thermostatSetpointSupportedReport !!!")
def cmds = []
cmds
}
def zwaveEventManufacturerProprietary(byte [] payload, payloadStr) {
log("DEBUG", ">>>>> ManufacturerProprietary(type:${String.format("%02X",payload[4])}, payload: ${payloadStr})")
def rslt = []
byte [] oldResp = [1,2,3,4]
def respType = 0
def diffCnt = 0
def oldP = ""
def newP = ""
def oldD = ""
def newD = ""
def head = ""
if (payload[1] == 0x40 && payload[4] == -124) {
respType = 84
oldResp = state.manProp1
if (oldResp == null) {oldResp = payload}
state.manProp1 = payload
rslt = process84Event(payload)
} else if (payload[1] == 0x40 && payload[4] == -121) {
respType = 87
oldResp = state.manProp2
if (oldResp == null) {oldResp = payload}
state.manProp2 = payload
rslt = process87Event(payload)
} else if (payload[1] == 0x41) {
respType = 41
oldResp = state.manProp3
if (oldResp == null) {oldResp = payload}
state.manProp3 = payload
// rslt = process41Event(payload)
} else {
log("WARN", DBG_ALWAYS, "Unexpected ManufacturersProprietary event received !!")
}
// log("DEBUG", "respType:${respType} oldResp: ${oldResp}")
if (oldResp == null) {
oldResp = (byte[])[0,1,2,3,4] as byte [];
log("DEBUG" , "==null forced to array")
}
try {
for (def i = 0; i < payload.length; i++) {
oldP += " ${String.format("%02X", oldResp[i])}"
newP += " ${String.format("%02X", payload[i])}"
oldD += " ${String.format("%03d", oldResp[i])}"
newD += " ${String.format("%03d", payload[i])}"
if (oldResp[i] != payload[i] && (
(respType == 84 && (i != CLOCK_MINUTE_84 && i != CLOCK_HOUR_84)) ||
(respType == 87 && (i != CLOCK_MINUTE_87 && i != CLOCK_HOUR_87)) ||
(respType == 41 && (i != 99))
)) {
diffCnt++
head += " ${String.format("%02d", i)} "
} else {
head += "--- "
}
}
} catch (e) {
log("DEBUG", "..... Exception in zwave.proprietary() byte lengths mismatch in round ${i} payload ${payload} of length ${payload.length} exception ${e}")
}
if (diffCnt) {
log("debug", DBG_MANF, "respType:${respType} differences:${diffCnt}\n__ __ ${head}\nnew-: ${newP}\nold-- : ${oldP}")
}
rslt
}
// Ver 3.1 firmware offsets (per logs from ethelredkent)
// Pool switch : 6
// waterTemp : 10
// airTempFreeze : 11
// airTempSolar : 12
private getADJ_84 () { (state.firmwareVersion == "3.1") ? -2 : 0 } // Determine the adjustment for old firmware
private getSWITCHES_84 () { 8 + ADJ_84 } // Bit mask of 5 switches. SW1 = 01X, SW5 = 10X
private getPOOL_SPA_MODE_84 () { 11 + ADJ_84 } // Pool/Spa mode. 01x Pool mode, 00x Spa mode
private getWATER_TEMP_84 () { 12 + ADJ_84 } // Water Temperature
private getAIR_TEMP_FREEZE_84 () { 13 + ADJ_84 } // Air Temperature for Freeze sensing
private getAIR_TEMP_SOLAR_84 () { 14 + ADJ_84 } // Air Temperature for Solar control
private getCLOCK_HOUR_84 () { 15 + ADJ_84 } // Clock Hour
private getCLOCK_MINUTE_84 () { 16 + ADJ_84 } // Clock Minute
private getVSP_SPEED_84 () { 20 + ADJ_84 } // VSP Speed bit mask. 01x = VSP1, 08x = VSP4
private getVER_MAIN_MAJOR_84 () { 21 + ADJ_84 } // Firmware version - PE653 - Major
private getVER_MAIN_MINOR_84 () { 22 + ADJ_84 } // Firmware version - PE653 - Minor
// Received a ManufacturerProprietary message. Pull the important details and update the UI controls
private process84Event(byte [] payload) {
log("DEBUG", DBG_MANF, "----- process84Event payload: ${payload}")
def rslt = []
def map = [:]
def str = ""
def val = 0
def ch = 0
def poolSpaMode = ""
Integer temp
state.firmwareVersion = "${payload[VER_MAIN_MAJOR_84]}.${payload[VER_MAIN_MINOR_84]}"
log("DEBUG", DBG_LOW, "----- process84Event Firmware-PE653: ${state.firmwareVersion} state.expansionVersion=${state.expansionVersion} EXPANSION_5043=${(EXPANSION_5043)} getP5043=${getEXPANSION_5043()} ")
def swMap = ['1':1, '2':2, '3':4, '4':8, '5':16]
for (sw in swMap) {
if (payload[SWITCHES_84] & sw.value) {
val = "on"
} else {
val = "off"
}
rslt.addAll(createMultipleEvents(sw.key.toInteger(), val, val))
}
// Set VSP indicators if enabled
if (VSP_ENABLED) {
for (vsp in ['1':1, '2':2, '3':4, '4':8]) {
if (payload[VSP_SPEED_84] & vsp.value) {
val = "on"
} else {
val = "off"
}
ch = getVSP_EP(vsp.key.toInteger())
rslt.addAll(createMultipleEvents(ch, val, val))
}
}
// Set Pool/Spa mode indicator
if (POOL_SPA_COMBO) {
if ( EXPANSION_5043 ) {
poolSpaMode = ((payload[POOL_SPA_MODE_84] & 0x01) == 0) ? "on" : "off"
} else {
poolSpaMode = ((payload[SWITCHES_84] & 0x08)) ? "on" : "off" // For P4xxx expansion report Sw4
}
rslt.addAll(createMultipleEvents(POOL_SPA_EP, poolSpaMode, poolSpaMode))
}
// If there is a heater and no P5043 expansion then it is connected to Switch 5
if (HAS_HEATER && !EXPANSION_5043) {
rslt.addAll(getHeaterEvents(payload[SWITCHES_84] & 0x10))
}
// Update Water Temperature
val = "${payload[WATER_TEMP_84] >= 0 ? payload[WATER_TEMP_84] : payload[WATER_TEMP_84] + 255}"
rslt.addAll(getWaterTempEvents(val, poolSpaMode))
// Update Freeze Air Temperature
// payload[AIR_TEMP_FREEZE_84] = -127 // test for negative
temp = payload[AIR_TEMP_FREEZE_84] >= 0 ? payload[AIR_TEMP_FREEZE_84] : payload[AIR_TEMP_FREEZE_84] + 255
rslt << createEvent(name: "airTempFreeze", value: temp, unit: "F", displayed: true, isStateChange: true)
// Update Solar Air Temperature
// payload[AIR_TEMP_SOLAR_84] = -125 // Test for negative
temp = payload[AIR_TEMP_SOLAR_84] >= 0 ? payload[AIR_TEMP_SOLAR_84] : payload[AIR_TEMP_SOLAR_84] + 255
rslt << createEvent(name: "airTempSolar", value: temp, unit: "F", displayed: true, isStateChange: true)
// Update Clock
def time1 = "${String.format("%02d",payload[CLOCK_HOUR_84])}:${String.format("%02d",payload[CLOCK_MINUTE_84])}"
rslt << createEvent(name: "clock", value: "${time1}", displayed: false, descriptionText: "PE653 Clock: ${time1}")
rslt
}
// The caller must tell us what mode the system is in because in the case of an 84 event, the device has not been updated yet,
private List getWaterTempEvents(temp, poolSpaMode) {
log("DEBUG", DBG_MANF, "----- getWaterTempEvents temp=$temp poolSpaMode=$poolSpaMode")
def cmds = []
if (poolSpaMode.equals("on")) {
cmds.addAll(createMultipleEvents(SPA_TEMPERATURE_EP, temp, temp))
cmds.addAll(createMultipleEvents(POOL_TEMPERATURE_EP, "unknown", "0"))
cmds.addAll(createMultipleEvents(SPA_THERMOSTATMODE_EP, null, "heat"))
cmds.addAll(createMultipleEvents(POOL_THERMOSTATMODE_EP, null, "off"))
} else {
cmds.addAll(createMultipleEvents(POOL_TEMPERATURE_EP, temp, temp))
cmds.addAll(createMultipleEvents(SPA_TEMPERATURE_EP, "unknown", "0"))
cmds.addAll(createMultipleEvents(POOL_THERMOSTATMODE_EP, null, "heat"))
cmds.addAll(createMultipleEvents(SPA_THERMOSTATMODE_EP, null, "off"))
}
cmds
}
private getVER_EXP_MAJOR_87 () { 12 } // Firmware version - PE653 - Major
private getVER_EXP_MINOR_87 () { 13 } // Firmware version - PE653 - Minor
private getHEATER_87 () { 15 } // Heater. 04x = on, 00x = off
private getCLOCK_HOUR_87 () { 24 } // Clock Hour
private getCLOCK_MINUTE_87 () { 25 } // Clock Minute
// Received a ManufacturerProprietary message. Pull the important details and update the UI controls
private process87Event(byte [] payload) {
log("DEBUG", DBG_MANF, "----- process87Event payload: ${payload}")
def cmds = []
log("DEBUG", DBG_MANF, "----- process87Event Firmware-Expansion: ${payload[VER_EXP_MAJOR_87]}.${payload[VER_EXP_MINOR_87]}")
// Only the P5043 expansion has its own firmware version. 3 = P5043, 0 = either no expansion or a P4xxx expansion
// A firmware version is only reported from a P5043 expansion. Even so, mine occasionally reports 8.0 instead. Seems to be the first report after the heater goes from on to off. Ignore this
def fVer = "${payload[VER_EXP_MAJOR_87]}.${payload[VER_EXP_MINOR_87]}"
if (fVer.take(1) == "3") {
state.expansionVersion = fVer
} else {
if (EXPANSION_5043) {
log("WARN", DBG_ALWAYS, "ManFac 87 message reported bogus version: $fVer after previously reporting $state.expansionVersion")
}
}
// If there is a P5043 expansion then the heater is connected there and reported in the 87 message
if (EXPANSION_5043) {
cmds.addAll(getHeaterEvents( payload[HEATER_87] & 0x04))
}
cmds
}
// Create the events to report the Heater state
private List getHeaterEvents(int heat) {
log("DEBUG", DBG_MANF, "----- getHeaterEvents heat: ${heat}")
def cmds = []
def locHeatState
def extHeatState
if (heat) {
locHeatState = "on"
extHeatState = "heating"
} else {
locHeatState = "off"
extHeatState = "idle"
}
if (device.currentValue("poolSpaMode").equals("on")) {
cmds.addAll(createMultipleEvents(SPA_THERMOSTATOPERATINGSTATE_EP, locHeatState, extHeatState))
cmds.addAll(createMultipleEvents(POOL_THERMOSTATOPERATINGSTATE_EP, null, "idle"))
} else {
cmds.addAll(createMultipleEvents(POOL_THERMOSTATOPERATINGSTATE_EP, locHeatState, extHeatState))
cmds.addAll(createMultipleEvents(SPA_THERMOSTATOPERATINGSTATE_EP, null, "idle"))
}
cmds
}