forked from yracine/device-type.myecobee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecobee.devicetype.groovy
3330 lines (3099 loc) · 131 KB
/
ecobee.devicetype.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
/***
* My Ecobee Device
* Copyright 2014 Yves Racine
* linkedIn profile: ca.linkedin.com/pub/yves-racine-m-sc-a/0/406/4b/
*
* Code: https://github.com/yracine/device-type.myecobee
* Refer to readme file for installation instructions.
*
*
* 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.
*
*/
// for the UI
preferences {
input("thermostatId", "text", title: "Serial #", description:
"The serial number of your thermostat (no spaces)")
input("appKey", "text", title: "App Key", description:
"The application key given by Ecobee (no spaces)")
input("trace", "text", title: "trace", description:
"Set it to true to enable tracing (no spaces) or leave it empty (no tracing)"
)
input("holdType", "text", title: "holdType", description:
"Set it to nextTransition or indefinite (latter by default)")
input("ecobeeType", "text", title: "ecobee Tstat Type", description:
"Set it to registered (by default) or managementSet (no spaces)")
}
metadata {
// Automatically generated. Make future change here.
definition(name: "My Ecobee Device", author: "Yves Racine", namespace: "yracine") {
capability "Relative Humidity Measurement"
capability "Temperature Measurement"
capability "Polling"
capability "Thermostat"
capability "Refresh"
capability "Presence Sensor"
capability "Actuator"
attribute "thermostatName", "string"
attribute "heatLevelUp", "string"
attribute "heatLevelDown", "string"
attribute "coolLevelUp", "string"
attribute "coolLevelDown", "string"
attribute "verboseTrace", "string"
attribute "fanMinOnTime", "string"
attribute "humidifierMode", "string"
attribute "dehumidifierMode", "string"
attribute "humidifierLevel", "string"
attribute "dehumidifierLevel", "string"
attribute "condensationAvoid", "string"
attribute "groups", "string"
attribute "equipmentStatus", "string"
attribute "alerts", "string"
attribute "programScheduleName", "string"
attribute "programFanMode", "string"
attribute "programType", "string"
attribute "programCoolTemp", "string"
attribute "programHeatTemp", "string"
attribute "programEndTimeMsg", "string"
attribute "weatherDateTime", "string"
attribute "weatherSymbol", "string"
attribute "weatherStation", "string"
attribute "weatherCondition", "string"
attribute "weatherTemperature", "string"
attribute "weatherPressure", "string"
attribute "weatherRelativeHumidity", "string"
attribute "weatherWindSpeed", "string"
attribute "weatherWindDirection", "string"
attribute "weatherPop", "string"
attribute "weatherTempHigh", "string"
attribute "weatherTempLow", "string"
attribute "plugName", "string"
attribute "plugState", "string"
attribute "plugSettings", "string"
attribute "hasHumidifier", "string"
attribute "hasDehumidifier", "string"
attribute "hasErv", "string"
attribute "hasHrv", "string"
attribute "ventilatorMinOnTime", "string"
attribute "ventilatorMode", "string"
attribute "programDisplayName", "string"
attribute "thermostatOperatingState", "string"
attribute "climateList", "string"
attribute "modelNumber", "string"
attribute "followMeComfort", "string"
attribute "autoAway", "string"
attribute "thermostatRevision", "string"
attribute "heatStages", "string"
attribute "coolStages", "string"
attribute "climateName", "string"
attribute "setClimate", "string"
// Report Runtime events
attribute "auxHeat1RuntimeInPeriod", "string"
attribute "auxHeat2RuntimeInPeriod", "string"
attribute "auxHeat3RuntimeInPeriod", "string"
attribute "compCool1RuntimeInPeriod", "string"
attribute "compCool2RuntimeInPeriod", "string"
attribute "dehumidifierRuntimeInPeriod", "string"
attribute "humidifierRuntimeInPeriod", "string"
attribute "ventilatorRuntimeInPeriod", "string"
attribute "fanRuntimeInPeriod", "string"
attribute "auxHeat1RuntimeDaily", "string"
attribute "auxHeat2RuntimeDaily", "string"
attribute "auxHeat3RuntimeDaily", "string"
attribute "compCool1RuntimeDaily", "string"
attribute "compCool2RuntimeDaily", "string"
attribute "dehumidifierRuntimeDaily", "string"
attribute "humidifierRuntimeDaily", "string"
attribute "ventilatorRuntimeDaily", "string"
attribute "fanRuntimeDaily", "string"
attribute "reportData", "string"
// Report Sensor Data & Stats
attribute "reportSensorMetadata", "string"
attribute "reportSensorData", "string"
attribute "reportSensorAvgInPeriod", "string"
attribute "reportSensorMinInPeriod", "string"
attribute "reportSensorMaxInPeriod", "string"
attribute "reportSensorTotalInPeriod", "string"
// Remote Sensor Data & Stats
attribute "remoteSensorData", "string"
attribute "remoteSensorTmpData", "string"
attribute "remoteSensorHumData", "string"
attribute "remoteSensorOccData", "string"
attribute "remoteSensorAvgTemp", "string"
attribute "remoteSensorAvgHumidity", "string"
attribute "remoteSensorMinTemp", "string"
attribute "remoteSensorMinHumidity", "string"
attribute "remoteSensorMaxTemp", "string"
attribute "remoteSensorMaxHumidity", "string"
command "setFanMinOnTime"
command "setCondensationAvoid"
command "createVacation"
command "deleteVacation"
command "getEcobeePinAndAuth"
command "getThermostatInfo"
command "getThermostatSummary"
command "iterateCreateVacation"
command "iterateDeleteVacation"
command "iterateResumeProgram"
command "iterateSetHold"
command "resumeProgram"
command "resumeThisTstat"
command "setAuthTokens"
command "setHold"
command "setHoldExtraParams"
command "heatLevelUp"
command "heatLevelDown"
command "coolLevelUp"
command "coolLevelDown"
command "auxHeatOnly"
command "setThermostatFanMode"
command "dehumidifierOff"
command "dehumidifierOn"
command "humidifierOff"
command "humidifierAuto"
command "humidifierManual"
command "setHumidifierLevel"
command "setDehumidifierLevel"
command "updateGroup"
command "getGroups"
command "iterateUpdateGroup"
command "createGroup"
command "deleteGroup"
command "updateClimate"
command "iterateUpdateClimate"
command "createClimate"
command "deleteClimate"
command "setClimate"
command "iterateSetClimate"
command "controlPlug" // not tested as I don't own a smartplug
command "ventilatorOn"
command "ventilatorAuto"
command "ventilatorOff"
command "ventilatorAuto"
command "setVentilatorMinOnTime"
command "awake"
command "away"
command "present"
command "home"
command "sleep"
command "quickSave"
command "setThisTstatClimate"
command "setThermostatSettings"
command "iterateSetThermostatSettings"
command "getEquipmentStatus"
command "refreshChildTokens"
command "autoAway"
command "followMeComfort"
command "getReportData"
command "generateReportRuntimeEvents"
command "generateReportSensorStatsEvents"
command "getThermostatRevision"
command "generateRemoteSensorEvents"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
valueTile("name", "device.thermostatName", inactiveLabel: false, width: 1,
height: 1, decoration: "flat") {
state "default", label: '${currentValue}\n'
}
valueTile("groups", "device.groups", inactiveLabel: false, width: 1,
height: 1, decoration: "flat") {
state "default", label: '${currentValue}'
}
valueTile("temperature", "device.temperature", width: 2, height: 2,
canChangeIcon: false) {
// If one prefers Celsius over Farenheits, just comment out the temperature in Farenheits
// and remove the comment below to have the right color scale in Celsius.
// This issue will be solved as soon as Smartthings supports dynamic tiles
// valueTile("temperature", "device.temperature", width: 2, height: 2) {
// state("temperature", label: '${currentValue}°', unit: "C",
// backgroundColors: [
// [value: 0, color: "#153591"],
// [value: 8, color: "#1e9cbb"],
// [value: 14, color: "#90d2a7"],
// [value: 20, color: "#44b621"],
// [value: 24, color: "#f1d801"],
// [value: 29, color: "#d04e00"],
// [value: 36, color: "#bc2323"]
// ])
// }
state("temperature", label:'${currentValue}°', unit:"F",
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
])
}
standardTile("mode", "device.thermostatMode", inactiveLabel: false,
decoration: "flat") {
state "heat", label: '${name}', action: "thermostat.off",
icon: "st.Weather.weather14", backgroundColor: "#ffffff"
state "off", label: '${name}', action: "thermostat.cool",
icon: "st.Outdoor.outdoor19"
state "cool", label: '${name}', action: "thermostat.auto",
icon: "st.Weather.weather7"
state "auto", action: "thermostat.heat",
icon: "st.thermostat.auto"
}
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false,
decoration: "flat") {
state "auto", label: '${name}', action: "thermostat.fanOn",
icon: "st.Appliances.appliances11"
state "on", label: '${name}', action: "thermostat.fanAuto",
icon: "st.Appliances.appliances11"
}
standardTile("switchProgram", "device.programDisplayName",
inactiveLabel: false, width: 1, height: 1, decoration: "flat") {
state "Home", label: '${name}', action: "sleep",
icon: "st.Home.home4"
state "Sleep", label: '${name}', action: "awake",
icon: "st.Bedroom.bedroom2"
state "Awake", label: '${name}', action: "away",
icon: "st.Outdoor.outdoor20"
state "Away", label: '${name}', action: "quickSave",
icon: "st.presence.car.car"
state "QuickSave", label: '${name}', action: "present",
icon: "st.Home.home1"
state "Custom", label: 'Custom', action: "resumeThisTstat",
icon: "st.Office.office6"
}
valueTile("heatingSetpoint", "device.heatingSetpoint", inactiveLabel: false,
decoration: "flat") {
state "heat", label: '${currentValue}° heat', unit: "F",
backgroundColor: "#ffffff"
}
valueTile("coolingSetpoint", "device.coolingSetpoint", inactiveLabel: false,
decoration: "flat") {
state "cool", label: '${currentValue}° cool', unit: "F",
backgroundColor: "#ffffff"
}
valueTile("humidity", "device.humidity", inactiveLabel: false,
decoration: "flat") {
state "default", label: 'Humidity\n${currentValue}%', unit: "humidity"
}
standardTile("heatLevelUp", "device.heatingSetpoint", canChangeIcon: false,
inactiveLabel: false, decoration: "flat") {
state "heatLevelUp", label: ' ', action: "heatLevelUp",
icon: "st.thermostat.thermostat-up"
}
standardTile("heatLevelDown", "device.heatingSetpoint", canChangeIcon: false,
inactiveLabel: false, decoration: "flat") {
state "heatLevelDown", label: ' ', action: "heatLevelDown",
icon:"st.thermostat.thermostat-down"
}
standardTile("coolLevelUp", "device.coolingSetpoint", canChangeIcon: false,
inactiveLabel: false, decoration: "flat") {
state "coolLevelUp", label: ' ', action: "coolLevelUp",
icon: "st.thermostat.thermostat-up"
}
standardTile("coolLevelDown", "device.coolingSetpoint", canChangeIcon: false,
inactiveLabel: false, decoration: "flat") {
state "coolLevelDown", label: ' ', action: "coolLevelDown",
icon: "st.thermostat.thermostat-down"
}
valueTile("equipStatus", "device.equipmentStatus", inactiveLabel: false,
decoration: "flat", width: 3, height: 1) {
state "default", label: '${currentValue}'
}
// One could also use thermostatOperatingState as display value for equipStatus (in line with default ecobee device's status)
// However, it does not contain humidifier/dehumidifer/HRV/ERV/aux heat
// components' running states, just the basic thermostat states (heating, cooling, fan only).
// To use this tile instead of the above, just comment out the above tile, and remove comments below.
// valueTile("equipStatus", "device.thermostatOperatingState", inactiveLabel: false,
// decoration: "flat", width: 3, height: 1) {
// state "default", label: '${currentValue}'
// }
valueTile("programEndTimeMsg", "device.programEndTimeMsg", inactiveLabel:
false, decoration: "flat", width: 3, height: 1) {
state "default", label: '${currentValue}'
}
valueTile("fanMinOnTime", "device.fanMinOnTime", inactiveLabel: false,
decoration: "flat", width: 1, height: 1) {
state "default", label: 'FanMin\n${currentValue}'
}
valueTile("alerts", "device.alerts", inactiveLabel: false, decoration: "flat",
width: 2, height: 1) {
state "default", label: '${currentValue}'
}
// Program Tiles
valueTile("programScheduleName", "device.programScheduleName", inactiveLabel:
false, width: 1, height: 1, decoration: "flat") {
state "default", label: 'Mode\n${currentValue}'
}
valueTile("programType", "device.programType", inactiveLabel: false, width: 1,
height: 1, decoration: "flat") {
state "default", label: 'Prog Type\n${currentValue}'
}
valueTile("programCoolTemp", "device.programCoolTemp", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'Prog Cool\n${currentValue}°'
}
valueTile("programHeatTemp", "device.programHeatTemp", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'Prog Heat\n${currentValue}°'
}
standardTile("resProgram", "device.thermostatMode", inactiveLabel: false,
decoration: "flat") {
state "default", label: 'ResumeProg', action: "resumeThisTstat",
icon: "st.Office.office7", backgroundColor: "#ffffff"
}
// Weather Tiles
standardTile("weatherIcon", "device.weatherSymbol", inactiveLabel: false, width: 1, height: 1,
decoration: "flat") {
state "-2", label: 'updating...', icon: "st.unknown.unknown.unknown"
state "0", label: 'Sunny', icon: "st.Weather.weather14"
state "1", label: 'FewClouds', icon: "st.Weather.weather15"
state "2", label: 'PartlyCloudy', icon: "st.Weather.weather15"
state "3", label: 'MostlyCloudy', icon: "st.Weather.weather15"
state "4", label: 'Overcast', icon: "st.Weather.weather13"
state "5", label: 'Drizzle', icon: "st.Weather.weather9"
state "6", label: 'Rain', icon: "st.Weather.weather10"
state "7", label: 'FreezingRain', icon: "st.Weather.weather10"
state "8", label: 'Showers', icon: "st.Weather.weather10"
state "9", label: 'Hail', icon: "st.custom.wuk.sleet"
state "10", label: 'Snow', icon: "st.Weather.weather6"
state "11", label: 'Flurries', icon: "st.Weather.weather6"
state "12", label: 'Sleet', icon: "st.Weather.weather6"
state "13", label: 'Blizzard', icon: "st.Weather.weather7"
state "14", label: 'Pellets', icon: "st.custom.wuk.sleet"
state "15", label: 'ThunderStorms', icon: "st.custom.wuk.tstorms"
state "16", label: 'Windy', icon: "st.Transportation.transportation5"
state "17", label: 'Tornado', icon: "st.Weather.weather1"
state "18", label: 'Fog', icon: "st.Weather.weather13"
state "19", label: 'Hazy', icon: "st.Weather.weather13"
state "20", label: 'Smoke', icon: "st.Weather.weather13"
state "21", label: 'Dust', icon: "st.Weather.weather13"
}
valueTile("weatherDateTime", "device.weatherDateTime", inactiveLabel: false,
width: 2, height: 1, decoration: "flat") {
state "default", label: '${currentValue}'
}
valueTile("weatherConditions", "device.weatherCondition",
inactiveLabel: false, width: 2, height: 1, decoration: "flat") {
state "default", label: 'Forecast\n${currentValue}'
}
valueTile("weatherTemperature", "device.weatherTemperature", inactiveLabel:
false, width: 1, height: 1, decoration: "flat") {
state "default", label: 'Out Temp\n${currentValue}°', unit: "C"
}
valueTile("weatherRelativeHumidity", "device.weatherRelativeHumidity",
inactiveLabel: false, width: 1, height: 1, decoration: "flat") {
state "default", label: 'Out Hum\n${currentValue}%', unit: "humidity"
}
valueTile("weatherTempHigh", "device.weatherTempHigh", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'FcastHigh\n${currentValue}°', unit: "C"
}
valueTile("weatherTempLow", "device.weatherTempLow", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'FcastLow\n${currentValue}°', unit: "C"
}
valueTile("weatherPressure", "device.weatherPressure", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'Pressure\n${currentValue}', unit: "hpa"
}
valueTile("weatherWindDirection", "device.weatherWindDirection",
inactiveLabel: false, width: 1, height: 1, decoration: "flat") {
state "default", label: 'W.Dir\n${currentValue}'
}
valueTile("weatherWindSpeed", "device.weatherWindSpeed", inactiveLabel: false,
width: 1, height: 1, decoration: "flat") {
state "default", label: 'W.Speed\n${currentValue}'
}
valueTile("weatherPop", "device.weatherPop", inactiveLabel: false, width: 1,
height: 1, decoration: "flat") {
state "default", label: 'PoP\n${currentValue}%', unit: "%"
}
standardTile("refresh", "device.thermostatMode", inactiveLabel: false,
decoration: "flat") {
state "default", action: "polling.poll", icon: "st.secondary.refresh"
}
main "temperature"
details(["name", "groups", "mode", "temperature", "fanMode", "switchProgram",
"heatLevelDown", "heatingSetpoint", "heatLevelUp", "coolLevelDown",
"coolingSetpoint", "coolLevelUp",
"equipStatus", "programEndTimeMsg", "humidity", "alerts",
"fanMinOnTime", "programScheduleName", "programType", "programCoolTemp",
"programHeatTemp", "resProgram",
"weatherIcon", "weatherDateTime", "weatherConditions",
"weatherTemperature", "weatherRelativeHumidity", "weatherTempHigh",
"weatherTempLow", "weatherPressure", "weatherWindDirection",
"weatherWindSpeed", "weatherPop", "refresh",
])
}
}
void coolLevelUp() {
int nextLevel = device.currentValue("coolingSetpoint") + 1
def scale = getTemperatureScale()
if (scale == 'C') {
if (nextLevel > 30) {
nextLevel = 30
}
} else {
if (nextLevel > 99) {
nextLevel = 99
}
}
setCoolingSetpoint(nextLevel)
}
void coolLevelDown() {
int nextLevel = device.currentValue("coolingSetpoint") - 1
def scale = getTemperatureScale()
if (scale == 'C') {
if (nextLevel < 10) {
nextLevel = 10
}
} else {
if (nextLevel < 50) {
nextLevel = 50
}
}
setCoolingSetpoint(nextLevel)
}
void heatLevelUp() {
int nextLevel = device.currentValue("heatingSetpoint") + 1
def scale = getTemperatureScale()
if (scale == 'C') {
if (nextLevel > 30) {
nextLevel = 30
}
} else {
if (nextLevel > 99) {
nextLevel = 99
}
}
setHeatingSetpoint(nextLevel)
}
void heatLevelDown() {
int nextLevel = device.currentValue("heatingSetpoint") - 1
def scale = getTemperatureScale()
if (scale == 'C') {
if (nextLevel < 10) {
nextLevel = 10
}
} else {
if (nextLevel < 50) {
nextLevel = 50
}
}
setHeatingSetpoint(nextLevel)
}
// handle commands
void setHeatingSetpoint(temp) {
def thermostatId= determine_tstat_id("")
setHold(thermostatId, device.currentValue("coolingSetpoint"), temp,
null, null)
sendEvent(name: 'heatingSetpoint', value: temp,unit: getTemperatureScale())
def currentMode = device.currentValue("thermostatMode")
if (currentMode=='heat') {
sendEvent("name":"thermostatSetpoint", "value": temp,unit: getTemperatureScale())
}
}
void setCoolingSetpoint(temp) {
def thermostatId= determine_tstat_id("")
setHold(settings.thermostatId, temp, device.currentValue("heatingSetpoint"),
null, null)
sendEvent(name: 'coolingSetpoint', value: temp,unit: getTemperatureScale())
def currentMode = device.currentValue("thermostatMode")
if (currentMode=='cool') {
sendEvent("name":"thermostatSetpoint", "value": temp,unit: getTemperatureScale())
}
}
void off() {
setThermostatMode('off')
}
void auto() {
setThermostatMode('auto')
}
void heat() {
setThermostatMode('heat')
}
void emergencyHeat() {
setThermostatMode('heat')
}
void auxHeatOnly() {
setThermostatMode('auxHeatOnly')
}
void cool() {
setThermostatMode('cool')
}
void setThermostatMode(mode) {
mode = mode == 'emergency heat' ? 'heat' : mode
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['hvacMode': "${mode}"])
sendEvent(name: 'thermostatMode', value: mode)
}
void fanOn() {
setThermostatFanMode('on')
}
void fanAuto() {
setThermostatFanMode('auto')
}
void fanOff() { // fanOff is not supported, setting it to 'auto' instead.
setThermostatFanMode('auto')
}
def fanCirculate() {
fanAuto()
setFanMinOnTime(15) // Set a minimum of 15 minutes of fan per hour
}
void setThermostatFanMode(mode) {
def thermostatId= determine_tstat_id("")
setHold(thermostatId, device.currentValue("coolingSetpoint"), device
.currentValue("heatingSetpoint"),
mode, null)
sendEvent(name: 'thermostatFanMode', value: mode)
}
void setFanMinOnTime(minutes) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['fanMinOnTime': "${minutes}"])
sendEvent(name: 'fanMinOnTime', value: minutes)
}
void ventilatorOn() {
setVentilatorMode('on')
}
void ventilatorOff() {
setVentilatorMode('off')
}
void ventilatorAuto() {
setVentilatorMode('auto')
}
void setVentilatorMinOnTime(minutes) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['vent': "minontime",
'ventilatorMinOnTime': "${minutes}"])
sendEvent(name: 'ventilatorMinOnTime', value: minutes)
sendEvent(name: 'ventilatorMode', value: "minontime")
}
void setVentilatorMode(mode) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['vent': "${mode}"])
sendEvent(name: 'ventilatorMode', value: mode)
}
void setCondensationAvoid(flag) { // set the flag to true or false
flag = flag == 'true' ? 'true' : 'false'
def mode = (flag=='true')? 'auto': 'manual'
setHumidifierMode(mode)
sendEvent(name: 'condensationAvoid', value: flag)
}
void dehumidifierOn() {
setDehumidifierMode('on')
}
void dehumidifierOff() {
setDehumidifierMode('off')
}
void setDehumidifierMode(mode) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['dehumidifierMode': "${mode}"])
sendEvent(name: 'dehumidifierMode', value: mode)
}
void setDehumidifierLevel(level) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['dehumidifierLevel': "${level}"])
sendEvent(name: 'dehumidifierLevel', value: level)
}
void humidifierAuto() {
setHumidifierMode('auto')
}
void humidifierManual() {
setHumidifierMode('manual')
}
void humidifierOff() {
setHumidifierMode('off')
}
void setHumidifierMode(mode) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['humidifierMode': "${mode}"])
sendEvent(name: 'humidifierMode', value: mode)
}
void setHumidifierLevel(level) {
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['humidity': "${level}"])
sendEvent(name: 'humidifierLevel', value: level)
}
void followMeComfort(flag) {
flag = flag == 'true' ? 'true' : 'false'
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['followMeComfort': "${flag}"])
sendEvent(name: 'followMeComfort', value: flag)
}
void autoAway(flag) {
flag = flag == 'true' ? 'true' : 'false'
def thermostatId= determine_tstat_id("")
setThermostatSettings(thermostatId, ['autoAway': "${flag}"])
sendEvent(name: 'autoAway', value: flag)
}
void awake() {
setThisTstatClimate("Awake")
}
void away() {
setThisTstatClimate("Away")
sendEvent(name: "presence", value: "not present")
}
void present() {
home()
}
void home() {
setThisTstatClimate("Home")
sendEvent(name: "presence", value: "present")
}
void sleep() {
setThisTstatClimate("Sleep")
}
void quickSave() {
def thermostatId= determine_tstat_id("")
def currentProgramType = device.currentValue("programType")
if (currentProgramType.toUpperCase() == 'VACATION') {
if (settings.trace) {
log.debug "quickSave>thermostatId = ${thermostatId},cannot do quickSave due to vacation settings"
sendEvent name: "verboseTrace", value:
"quickSave>thermostatId = ${thermostatId},cannot do quickSave switch due to vacation settings"
}
return
}
float quickSaveSetBack, quickSaveSetForw, quickSaveHeating, quickSaveCooling
def scale = getTemperatureScale()
if (scale == 'C') {
quickSaveSetBack = data.thermostatList[0].settings.quickSaveSetBack / 2 // approximate conversion of differential to celcius
quickSaveSetForw = data.thermostatList[0].settings.quickSaveSetForward / 2
quickSaveCooling = fToC(data.thermostatList[0].runtime.desiredCool)
quickSaveHeating = fToC(data.thermostatList[0].runtime.desiredHeat)
} else {
quickSaveSetBack = data.thermostatList[0].settings.quickSaveSetBack
quickSaveSetForw = data.thermostatList[0].settings.quickSaveSetForward
quickSaveCooling = data.thermostatList[0].runtime.desiredCool
quickSaveHeating = data.thermostatList[0].runtime.desiredHeat
}
quickSaveCooling = (quickSaveCooling + quickSaveSetForw).round(0)
quickSaveHeating = (quickSaveHeating - quickSaveSetBack).round(0)
setHold(thermostatId, quickSaveCooling, quickSaveHeating, null, null)
def quickSaveMap = ['coolingSetpoint': quickSaveCooling,
'heatingSetpoint': quickSaveHeating,
'programScheduleName': "QuickSave",
'programDisplayName': "QuickSave"
]
generateEvent(quickSaveMap)
}
void setThisTstatClimate(climateName) {
def thermostatId= determine_tstat_id("")
def currentProgram = device.currentValue("programScheduleName")
def currentProgramType = device.currentValue("programType").trim().toUpperCase()
if (currentProgramType == 'VACATION') {
if (settings.trace) {
log.debug "setThisTstatClimate>thermostatId = ${settings.thermostatId},cannot do the prog switch due to vacation settings"
sendEvent name: "verboseTrace", value:
"setThisTstatClimate>thermostatId = ${settings.thermostatId},cannot do the prog switch due to vacation settings"
}
return
}
// If climate is different from current one, then change it to the given climate
if (currentProgram.toUpperCase() != climateName.trim().toUpperCase()) {
resumeProgram(thermostatId)
setClimate(thermostatId, climateName)
sendEvent(name: 'programScheduleName', value: climateName)
poll() // to refresh the values in the UI
}
}
// parse events into attributes
def parse(String description) {
}
void poll() {
def tstatId,ecobeeType
def thermostatId= determine_tstat_id("")
getThermostatInfo(thermostatId)
// determine if there is an event running
Integer indiceEvent = 0
Boolean foundEvent = false
if (data.thermostatList[0].events.size > 0) {
for (i in 0..data.thermostatList[0].events.size() - 1) {
if (data.thermostatList[0].events[i].running) {
indiceEvent = i // save the right indice associated to the Event that is currently running
foundEvent = true
exit
}
}
}
def currentClimate = null
// Get the current Climate
data.thermostatList[0].program.climates.each() {
if (it.climateRef == data.thermostatList[0].program.currentClimateRef) {
currentClimate = it
exit
}
}
ecobeeType = determine_ecobee_type_or_location(ecobeeType)
def progDisplayName = getCurrentProgName()
def currentClimateTemplate= (data.thermostatList[0].program.currentClimateRef)? currentClimate.name: progDisplayName // if no program's climate set, then use current program
if (settings.trace) {
log.debug "poll>thermostatId = ${thermostatId},Current Climate Ref=${data.thermostatList[0].program.currentClimateRef},currentClimateTemplate=${currentClimateTemplate}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},Current Climate Ref=${data.thermostatList[0].program.currentClimateRef},currentClimateTemplate=${currentClimateTemplate}"
if (foundEvent) {
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},indiceEvent=${indiceEvent}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event name=${data.thermostatList[0].events[indiceEvent].name}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event type=${data.thermostatList[0].events[indiceEvent].type}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's coolHoldTemp=${data.thermostatList[0].events[indiceEvent].coolHoldTemp}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's heatHoldTemp=${data.thermostatList[0].events[indiceEvent].heatHoldTemp}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's fan mode=${data.thermostatList[0].events[indiceEvent].fan}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's fanMinOnTime=${data.thermostatList[0].events[indiceEvent].fanMinOnTime}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's vent mode=${data.thermostatList[0].events[indiceEvent].vent}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's ventilatorMinOnTime=${data.thermostatList[0].events[indiceEvent].ventilatorMinOnTime}"
sendEvent name: "verboseTrace", value:
"poll>thermostatId = ${thermostatId},event's running=${data.thermostatList[0].events[indiceEvent].running}"
}
}
def dataEvents = [
thermostatName:data.thermostatList[0].name,
thermostatMode:data.thermostatList[0].settings.hvacMode,
temperature: data.thermostatList[0].runtime.actualTemperature,
humidity:data.thermostatList[0].runtime.actualHumidity,
coolingSetpoint: (foundEvent)? data.thermostatList[0].events[indiceEvent].coolHoldTemp:
data.thermostatList[0].runtime.desiredCool,
heatingSetpoint: (foundEvent)? data.thermostatList[0].events[indiceEvent].heatHoldTemp:
data.thermostatList[0].runtime.desiredHeat,
modelNumber: data.thermostatList[0].modelNumber,
equipmentStatus:getEquipmentStatus(),
thermostatOperatingState: getThermostatOperatingState(),
hasHumidifier:data.thermostatList[0].settings.hasHumidifier.toString(),
hasDehumidifier:data.thermostatList[0].settings.hasDehumidifier.toString(),
hasHrv:data.thermostatList[0].settings.hasHrv.toString(),
hasErv:data.thermostatList[0].settings.hasErv.toString(),
programScheduleName: (foundEvent)? data.thermostatList[0].events[indiceEvent].name : currentClimate.name,
programType: (foundEvent)?data.thermostatList[0].events[indiceEvent].type : currentClimate.type,
programEndTimeMsg: (foundEvent)? "${data.thermostatList[0].events[indiceEvent].type}" +
" ends at ${data.thermostatList[0].events[indiceEvent].endDate} " +
"${data.thermostatList[0].events[indiceEvent].endTime.substring(0,5)}":
"No Events running",
thermostatFanMode: (foundEvent)? data.thermostatList[0].events[indiceEvent].fan:
data.thermostatList[0].runtime.desiredFanMode,
fanMinOnTime: (foundEvent)? data.thermostatList[0].events[indiceEvent].fanMinOnTime.toString() :
data.thermostatList[0].settings.fanMinOnTime.toString(),
programFanMode: (data.thermostatList[0].settings.hvacMode == 'cool')? currentClimate.coolFan : currentClimate.heatFan,
programDisplayName: progDisplayName,
weatherStation:data.thermostatList[0].weather.weatherStation,
weatherSymbol:data.thermostatList[0].weather.forecasts[0].weatherSymbol.toString(),
weatherTemperature:data.thermostatList[0].weather.forecasts[0].temperature,
weatherDateTime:"Weather as of\n ${data.thermostatList[0].weather.forecasts[0].dateTime.substring(0,16)}",
weatherCondition:data.thermostatList[0].weather.forecasts[0].condition,
weatherTemp: data.thermostatList[0].weather.forecasts[0].temperature,
weatherTempHigh: data.thermostatList[0].weather.forecasts[0].tempHigh,
weatherTempLow: data.thermostatList[0].weather.forecasts[0].tempLow,
weatherWindSpeed: (data.thermostatList[0].weather.forecasts[0].windSpeed/1000), // divided by 1000 for display
weatherPressure:data.thermostatList[0].weather.forecasts[0].pressure.toString(),
weatherRelativeHumidity:data.thermostatList[0].weather.forecasts[0].relativeHumidity,
weatherWindDirection:data.thermostatList[0].weather.forecasts[0].windDirection + " Winds",
weatherPop:data.thermostatList[0].weather.forecasts[0].pop.toString(),
programCoolTemp:(currentClimate.coolTemp / 10), // divided by 10 for display
programHeatTemp:(currentClimate.heatTemp / 10),
alerts: getAlerts(),
groups: (ecobeeType.toUpperCase() == 'REGISTERED')? getThermostatGroups(thermostatId) : 'No groups',
climateList: getClimateList(),
presence: (currentClimateTemplate.toUpperCase()!='AWAY')? "present":"not present",
heatStages:data.thermostatList[0].settings.heatStages.toString(),
coolStages:data.thermostatList[0].settings.coolStages.toString(),
climateName: currentClimate.name,
setClimate: currentClimateTemplate
]
if (foundEvent && (data.thermostatList[0]?.events[indiceEvent]?.type == 'quickSave')) {
dataEvents.programEndTimeMsg ="Quicksave running"
}
generateEvent(dataEvents)
if (data.thermostatList[0].settings.hasHumidifier) {
sendEvent(name: 'humidifierMode', value: data.thermostatList[0].settings.humidifierMode)
sendEvent(name: 'humidifierLevel', value: data.thermostatList[0].settings.humidity,
unit: "%")
}
if (data.thermostatList[0].settings.hasDehumidifier) {
sendEvent(name: 'dehumidifierMode', value: data.thermostatList[0].settings.dehumidifierMode)
sendEvent(name: 'dehumidifierLevel', value: data.thermostatList[0].settings.dehumidifierLevel,
unit: "%")
}
if ((data.thermostatList[0].settings.hasHrv) || (data.thermostatList[0].settings
.hasErv)) {
sendEvent(name: 'ventilatorMinOnTime', value: data.thermostatList[0].settings
.ventilatorMinOnTime)
sendEvent(name: 'ventilatorMode', value: data.thermostatList[0].settings.vent)
}
}
private void generateEvent(Map results)
{
if (settings.trace) {
log.debug "generateEvents>parsing data $results"
}
if(results)
{
results.each { name, value ->
def isDisplayed = true
// Temperature variable names contain 'temp' or 'setpoint'
if ((name.toUpperCase().contains("TEMP"))|| (name.toUpperCase().contains("SETPOINT"))) {
String tempValueString
Double tempValue
def scale = getTemperatureScale()
if (scale == "F") {
tempValue = getTemperature(value).toDouble().round()
tempValueString = String.format('%2d', tempValue.intValue())
} else {
tempValue = getTemperature(value).toDouble().round(1)
tempValueString = String.format('%2.1f', tempValue)
}
def isChange = isTemperatureStateChange(device, name, tempValueString)
isDisplayed = isChange
sendEvent(name: name, value: tempValueString, unit: scale, displayed: isDisplayed)
} else if (name.toUpperCase().contains("SPEED")) { // Temperature variable names contain 'temp' or 'setpoint'
// Speed variable names contain 'speed'
float speedValue = getSpeed(value).toFloat().round(1)
def isChange = isStateChange(device, name, speedValue.toString())
isDisplayed = isChange
sendEvent(name: name, value: speedValue.toString(), unit: getDistanceScale(), displayed: isDisplayed)
} else if (name.toUpperCase().contains("HUMIDITY")) {
float humidityValue = value.toFloat().round(1)
def isChange = isStateChange(device, name, humidityValue.toString())
isDisplayed = isChange
sendEvent(name: name, value: humidityValue.toString(), unit: "%", displayed: isDisplayed)
} else {
def isChange = isStateChange(device, name, value)
isDisplayed = isChange
sendEvent(name: name, value: value, isStateChange: isChange, displayed: isDisplayed)
}
}
}
}
private def getCurrentProgName() {
def AWAY_PROG = 'Away'
def SLEEP_PROG = 'Sleep'
def HOME_PROG = 'Home'
def AWAKE_PROG = 'Awake'
def CUSTOM_PROG = 'Custom'
def QUICKSAVE = 'QuickSave'
def progCurrentName = device.currentValue("programScheduleName")
def progType = device.currentValue("programType")
progType = (progType == null) ? "": progType.trim().toUpperCase()
progCurrentName = (progCurrentName == null) ? "": progCurrentName.trim().toUpperCase()
if ((progCurrentName != AWAY_PROG) && (progCurrentName != SLEEP_PROG) && (
progCurrentName != AWAKE_PROG) &&
(progCurrentName != HOME_PROG) && (progCurrentName != QUICKSAVE)) {
progCurrentName = (progType == 'VACATION') ? AWAY_PROG : CUSTOM_PROG
}
return progCurrentName
}
private def getAlerts() {
def alerts = null
if (data.thermostatList[0].alerts.size() > 0) {
alerts = 'Alert(s) '
for (i in 0..data.thermostatList[0].alerts.size() - 1) {
alerts = (i > 0) ? ' \n' + alerts + data.thermostatList[0].alerts[i].notificationType :
alerts +
data.thermostatList[0].alerts[i].notificationType
}
}
alerts = (alerts != null) ? alerts + '\ngo to ecobee portal' : 'No alerts'
return alerts
}
private def getThermostatGroups(thermostatId) {
def groupList = 'No groups'
getGroups(thermostatId)
if (data.groups.size() > 0) {
groupList = 'Group(s) '
def j=0
for (i in 0..data.groups.size() - 1) {
if (data.groups[i].groupName != '') {
groupList = (j > 0) ? ' \n' + groupList + data.groups[i].groupName :
groupList + data.groups[i].groupName
j++
}
}
}
return groupList
}
private def getTemperature(value) {
def farenheits = value
if(getTemperatureScale() == "F"){
return farenheits
} else {
return fToC(farenheits)
}
}
private def getSpeed(value) {
def miles = value
if(getTemperatureScale() == "F"){
return miles
} else {
return milesToKm(miles)
}
}