forked from adampv/smartthings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeatitZWaveThermostat.groovy
1219 lines (1116 loc) · 43.4 KB
/
HeatitZWaveThermostat.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
/**
* Copyright 2016 AdamV
*
* 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.
*
* V0.9.3 20/09/2016
*
*
* Changelog:
*
* 0.9.3 - Corrected the energySaveHeat Command so that you can specifically activate this from CoRE rules
* 0.9.2 - Fixed an issue preventing some commands being fired when they are not triggered from the DTH UI
*/
preferences {
def myOptions = ["F - Floor temperature mode", "A - Room temperature mode", "AF - Room mode w/floor limitations", "A2 - Room temperature mode (external)", "P - Power regulator mode", "FP - Floor mode with minimum power limitation"]
input "tempSen",
"enum",
title: "Select Temperature Sensor Mode",
// description: "F - Floor mode: Regulation is based on the floor temperature sensor reading \nA - Room temperature mode: Regulation is based on the measured room temperature using the internal sensor (Default) \nAF - Room mode w/floor limitations: Regulation is based on internal room sensor but limited by the floor temperature sensor (included) ensuring that the floor temperature stays within the given limits (FLo/FHi) \nA2 - Room temperature mode: Regulation is based on the measured room temperature using the external sensor \nP (Power regulator): Constant heating power is supplied to the floor. Power rating is selectable in 10% increments ( 0% - 100%) \nFP - Floor mode with minimum power limitation: Regulation is based on the floor temperature sensor reading, but will always heat with a minimum power setting (PLo)",
defaultValue: "A - Room temperature mode",
required: true,
options: myOptions,
displayDuringSetup: false
input title: "Explanation:",
description: "F - Floor mode: Regulation is based on the floor temperature sensor reading \nA - Room temperature mode: Regulation is based on the measured room temperature using the internal sensor (Default) \nAF - Room mode w/floor limitations: Regulation is based on internal room sensor but limited by the floor temperature sensor (included) ensuring that the floor temperature stays within the given limits (FLo/FHi) \nA2 - Room temperature mode: Regulation is based on the measured room temperature using the external sensor \nP (Power regulator): Constant heating power is supplied to the floor. Power rating is selectable in 10% increments ( 0% - 100%) \nFP - Floor mode with minimum power limitation: Regulation is based on the floor temperature sensor reading, but will always heat with a minimum power setting (PLo)",
displayDuringSetup: false,
type: "paragraph",
element: "paragraph"
input "FLo",
"number",
range: "5..40",
title: "FLo: Floor min limit",
description: "Minimum Limit for floor sensor (5°-40°)",
defaultValue: 5,
required: false,
displayDuringSetup: false
input "FHi",
"number",
range: "5..40",
title: "FHi: Floor max limit",
description: "Maximum Limit for floor sensor (5°-40°)",
defaultValue: 40,
required: false,
displayDuringSetup: false
def sensOptions = ["10k ntc (Default)", "12k ntc", "15k ntc", "22k ntc", "33k ntc", "47k ntc"]
input "sensorType",
"enum",
title: "Select Floor Sensor Type",
//description: "",
defaultValue: "10k ntc (Default)",
required: false,
options: sensOptions,
displayDuringSetup: false
input "ALo",
"number",
range: "5..40",
title: "ALo: Air min limit",
description: "Minimum Limit for Air sensor (5°-40°)",
defaultValue: 5,
required: false,
displayDuringSetup: false
input "AHi",
"number",
range: "5..40",
title: "AHi: Air max limit",
description: "Maximum Limit for Air sensor (5°-40°)",
defaultValue: 40,
required: false,
displayDuringSetup: false
input "PLo",
"number",
range: "0..9",
title: "PLo: FP-mode P setting",
description: "FP-mode P setting (0 - 9)",
defaultValue: 0,
required: false,
displayDuringSetup: false
def pOptions = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
input "PSet",
"enum",
//range: "0..100",
title: "PSetting",
description: "Power Regulator setting (0 - 100%)",
defaultValue: "20%",
required: false,
options: pOptions,
displayDuringSetup: false
}
/*
def updated() {
if (settings.tempSen == null) settings.tempSen = "A - Room temperature mode"
configure()
}
*/
metadata {
definition (name: "heatit Thermostat", namespace: "heatit", author: "AdamV") {
capability "Actuator"
capability "Temperature Measurement"
//capability "Relative Humidity Measurement"
capability "Thermostat"
capability "Thermostat Mode"
capability "Thermostat Heating Setpoint"
capability "Thermostat Setpoint"
capability "Configuration"
capability "Polling"
capability "Sensor"
//attribute "thermostatFanState", "string"
command "switchMode"
command "energySaveHeat"
//command "switchFanMode"
//command "quickSetCool"
command "quickSetHeat"
command "quickSetecoHeat"
command "pressUp"
command "pressDown"
fingerprint deviceId: "0x0806"
fingerprint inClusters: "0x5E, 0x43, 0x31, 0x86, 0x40, 0x59, 0x85, 0x73, 0x72, 0x5A, 0x70"
}
// simulator metadata
simulator {
status "off" : "command: 4003, payload: 00"
status "heat" : "command: 4003, payload: 01"
status "cool" : "command: 4003, payload: 02"
status "auto" : "command: 4003, payload: 03"
status "emergencyHeat" : "command: 4003, payload: 04"
status "fanAuto" : "command: 4403, payload: 00"
status "fanOn" : "command: 4403, payload: 01"
status "fanCirculate" : "command: 4403, payload: 06"
status "heat 60" : "command: 4303, payload: 01 09 3C"
status "heat 68" : "command: 4303, payload: 01 09 44"
status "heat 72" : "command: 4303, payload: 01 09 48"
status "cool 72" : "command: 4303, payload: 02 09 48"
status "cool 76" : "command: 4303, payload: 02 09 4C"
status "cool 80" : "command: 4303, payload: 02 09 50"
status "temp 58" : "command: 3105, payload: 01 2A 02 44"
status "temp 62" : "command: 3105, payload: 01 2A 02 6C"
status "temp 70" : "command: 3105, payload: 01 2A 02 BC"
status "temp 74" : "command: 3105, payload: 01 2A 02 E4"
status "temp 78" : "command: 3105, payload: 01 2A 03 0C"
status "temp 82" : "command: 3105, payload: 01 2A 03 34"
status "idle" : "command: 4203, payload: 00"
status "heating" : "command: 4203, payload: 01"
status "cooling" : "command: 4203, payload: 02"
status "fan only" : "command: 4203, payload: 03"
status "pending heat" : "command: 4203, payload: 04"
status "pending cool" : "command: 4203, payload: 05"
status "vent economizer": "command: 4203, payload: 06"
// reply messages
reply "2502": "command: 2503, payload: FF"
}
tiles (scale: 2){
multiAttributeTile(name:"thermostatMulti", type:"thermostat", width:6, height:4) {
tileAttribute("device.temperature", key: "PRIMARY_CONTROL") {
attributeState("default", label:'${currentValue}°', unit:"C", action:"switchMode", icon:"st.Home.home1")
}
/* tileAttribute("device.heatingSetpoint", key: "VALUE_CONTROL") {
attributeState "heat", action:"quickSetHeat"
}
*/
tileAttribute("device.heatingSetpoint", key: "VALUE_CONTROL") {
attributeState("VALUE_UP", action: "pressUp")
attributeState("VALUE_DOWN", action: "pressDown")
}
//tileAttribute("device.heatingSetpoint", key: "SECONDARY_CONTROL") {
tileAttribute("device.tempSenseMode", key: "SECONDARY_CONTROL") {
attributeState("default", label:'${currentValue}', unit:"", icon:" ")
//attributeState("default", label:'${currentValue}°', unit:"°", icon:"st.Weather.weather2")
}
tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
attributeState("idle", backgroundColor:"#44b621")
attributeState("heating", backgroundColor:"#bc2323")
attributeState("energySaveHeat", backgroundColor:"#ffa81e")
}
tileAttribute("device.thermostatMode", key: "THERMOSTAT_MODE") {
attributeState("off", label:'${name}', action:"switchMode", nextState:"heat")
attributeState("heat", label:'${name}', action:"switchMode", nextState:"energy")
attributeState("energySaveHeat", label:'${name}', action:"switchMode", nextState:"off")
}
tileAttribute("device.heatingSetpoint", key: "HEATING_SETPOINT") {
attributeState("default", label:'${currentValue}')
}
}
/*
valueTile("temperature", "device.temperature", width: 2, height: 2) {
state("temperature", label:'${currentValue}°',
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"]
]
)
}
*/
valueTile("mode", "device.thermostatMode", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "off", label:'${name}', action:"switchMode", nextState:"to_heat"
state "heat", label:'${name}', action:"switchMode", nextState:"energySaveHeat"
//state "cool", label:'${name}', action:"switchMode", nextState:"..."
// state "auto", label:'${name}', action:"switchMode", nextState:"energySaveHeat"
//state "emergency heat", label:'${name}', action:"switchMode", nextState:"energySaveHeat"
//state "to_heat", label: "heat", action:"switchMode", nextState:"energySaveHeat"
//state "to_cool", label: "cool", action:"switchMode", nextState:"..."
state "energySaveHeat", label: "eco heat", action:"switchMode", nextState:"off"
}
/*
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false, decoration: "flat") {
state "fanAuto", label:'${name}', action:"switchFanMode"
state "fanOn", label:'${name}', action:"switchFanMode"
state "fanCirculate", label:'${name}', action:"switchFanMode"
}
*/
valueTile("heatLabel", "device.thermostatMode", inactiveLabel: false, decoration: "flat", height: 1, width: 4) {
state "default", label:"Heat Set Point:"
}
controlTile("heatSliderControl", "device.heatingSetpoint", "slider", height: 1, width: 4, inactiveLabel: false, range: "(5..40)") {
state "setHeatingSetpoint", action:"quickSetHeat", backgroundColor:"#d04e00"
}
// standardTile("blank", "device.thermostatMode", inactiveLabel: false, decoration: "flat", height: 2, width: 2) {
// state "default", label:""
// }
valueTile("ecoLabel", "device.thermostatMode", inactiveLabel: false, decoration: "flat", height: 1, width: 4) {
state "default", label:"Eco Mode Set Point:"
}
controlTile("ecoheatSliderControl", "device.ecoheatingSetpoint", "slider", height: 1, width: 4, inactiveLabel: false, range: "(5..40)") {
state "setecoHeatingSetpoint", action:"quickSetecoHeat", backgroundColor:"#d04e00"
}
/*
valueTile("heatingSetpoint", "device.heatingSetpoint", inactiveLabel: false, decoration: "flat") {
state "heat", label:'${currentValue}° heat', backgroundColor:"#ffffff"
}
/*
controlTile("coolSliderControl", "device.coolingSetpoint", "slider", height: 1, width: 2, inactiveLabel: false) {
state "setCoolingSetpoint", action:"quickSetCool", backgroundColor: "#1e9cbb"
}
valueTile("coolingSetpoint", "device.coolingSetpoint", inactiveLabel: false, decoration: "flat") {
state "cool", label:'${currentValue}° cool', backgroundColor:"#ffffff"
}
*/
standardTile("refresh", "device.thermostatMode", inactiveLabel: false, decoration: "flat", height: 2, width: 2) {
state "default", action:"polling.poll", icon:"st.secondary.refresh"
}
standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat", height: 2, width: 2) {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}
main "thermostatMulti"
details(["thermostatMulti", "mode", "heatLabel", "heatSliderControl", "refresh", "ecoLabel", "ecoheatSliderControl", "configure"])
}
}
def parse(String description) {
def results = []
// log.debug("RAW command: $description")
if (description.startsWith("Err")) {
log.debug("An error has occurred")
}
else {
def cmd = zwave.parse(description.replace("98C1", "9881"), [0x98: 1, 0x20: 1, 0x84: 1, 0x80: 1, 0x60: 3, 0x2B: 1, 0x26: 1])
// log.debug "Parsed Command: $cmd"
if (cmd) {
results = zwaveEvent(cmd)
}
}
}
/*def parse(String description)
{
log.debug(description)
def map = createEvent(zwaveEvent(zwave.parse(description, [0x42:1, 0x43:2, 0x31:3])))
if (!map) {
return null
}
def result = [map]
if (map.isStateChange && map.name in ["heatingSetpoint","coolingSetpoint","thermostatMode"]) {
def map2 = [
name: "thermostatSetpoint",
unit: getTemperatureScale()
]
if (map.name == "thermostatMode") {
state.lastTriedMode = map.value
if (map.value == "cool") {
map2.value = device.latestValue("coolingSetpoint")
log.info "THERMOSTAT, latest cooling setpoint = ${map2.value}"
}
else {
map2.value = device.latestValue("heatingSetpoint")
log.info "THERMOSTAT, latest heating setpoint = ${map2.value}"
}
}
else {
def mode = device.latestValue("thermostatMode")
log.info "THERMOSTAT, latest mode = ${mode}"
if ((map.name == "heatingSetpoint" && mode == "heat") || (map.name == "coolingSetpoint" && mode == "cool")) {
map2.value = map.value
map2.unit = map.unit
}
}
if (map2.value != null) {
log.debug "THERMOSTAT, adding setpoint event: $map"
result << createEvent(map2)
}
} else if (map.name == "thermostatFanMode" && map.isStateChange) {
state.lastTriedFanMode = map.value
}
log.debug "Parse returned $result"
result
}
*/
// Event Generation
def zwaveEvent(physicalgraph.zwave.commands.thermostatsetpointv2.ThermostatSetpointReport cmd)
{
if (cmd.setpointType == 1){
def heating = cmd.scaledValue
sendEvent(name: "heatingSetpoint", value: heating)
}
if (cmd.setpointType == 2){
def energyHeating = cmd.scaledValue
sendEvent(name: "ecoHeatingSetpoint", value: energyHeating)
state.ecoheatingSetpoint = energyHeating
}
// log.debug(heatingSetpoint)
// state.heatingSetpoint = heatingSetpoint
//def cmdScale = cmd.scale == 1 ? "F" : "C"
/*def map = [:]
map.value = convertTemperatureIfNeeded(cmd.scaledValue, cmdScale, cmd.precision)
map.unit = getTemperatureScale()
map.displayed = false
switch (cmd.setpointType) {
case 1:
map.name = "heatingSetpoint"
break;
case 2:
map.name = "coolingSetpoint"
break;
default:
return [:]
}
*/
// So we can respond with same format
state.size = cmd.size
state.scale = cmd.scale
state.precision = cmd.precision
//map
}
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd){
log.debug("Sensor report: $cmd")
//def precision = cmd.precision / 10
log.debug("Precision: $precision °C")
if (cmd.scale == 0){
log.debug("Scale is Celcius")
}
log.debug("Air Temperature is: $cmd.scaledSensorValue °C")
sendEvent(name: "temperature", value: cmd.scaledSensorValue)
/* def map = [:]
if (cmd.sensorType == 1) {
map.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmd.scale == 1 ? "F" : "C", cmd.precision)
map.unit = getTemperatureScale()
map.name = "temperature"
} else if (cmd.sensorType == 5) {
map.value = cmd.scaledSensorValue
map.unit = "%"
map.name = "humidity"
}
map*/
}
def zwaveEvent(physicalgraph.zwave.commands.thermostatoperatingstatev2.ThermostatOperatingStateReport cmd)
{
log.debug("operating rep: $cmd")
def map = [:]
switch (cmd.operatingState) {
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_IDLE:
map.value = "idle"
break
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_HEATING:
map.value = "heating"
break
/*
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_COOLING:
map.value = "cooling"
break
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_FAN_ONLY:
map.value = "fan only"
break
*/
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_PENDING_HEAT:
map.value = "pending heat"
break
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_PENDING_COOL:
map.value = "pending cool"
break
case physicalgraph.zwave.commands.thermostatoperatingstatev1.ThermostatOperatingStateReport.OPERATING_STATE_VENT_ECONOMIZER:
map.value = "vent economizer"
break
}
map.name = "thermostatOperatingState"
map
}
/*
def zwaveEvent(physicalgraph.zwave.commands.thermostatfanstatev1.ThermostatFanStateReport cmd) {
def map = [name: "thermostatFanState", unit: ""]
switch (cmd.fanOperatingState) {
case 0:
map.value = "idle"
break
case 1:
map.value = "running"
break
case 2:
map.value = "running high"
break
}
map
}
*/
def zwaveEvent(physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport cmd) {
def map = [:]
switch (cmd.mode) {
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_OFF:
map.value = "off"
sendEvent(name: "thermostatOperatingState", value: "idle")
break
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_HEAT:
map.value = "heat"
sendEvent(name: "thermostatOperatingState", value: "heating")
break
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_AUXILIARY_HEAT:
map.value = "emergency heat"
break
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_COOL:
map.value = "cool"
break
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_AUTO:
map.value = "auto"
break
case physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeReport.MODE_ENERGY_SAVE_HEAT:
map.value = "energySaveHeat"
sendEvent(name: "thermostatOperatingState", value: "energySaveHeat")
break
}
map.name = "thermostatMode"
map
}
def zwaveEvent(physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeReport cmd) {
def map = [:]
switch (cmd.fanMode) {
case physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeReport.FAN_MODE_AUTO_LOW:
map.value = "fanAuto"
break
case physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeReport.FAN_MODE_LOW:
map.value = "fanOn"
break
case physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeReport.FAN_MODE_CIRCULATION:
map.value = "fanCirculate"
break
}
map.name = "thermostatFanMode"
map.displayed = false
map
}
def zwaveEvent(physicalgraph.zwave.commands.thermostatmodev2.ThermostatModeSupportedReport cmd) {
log.debug("support reprt: $cmd")
def supportedModes = ""
if(cmd.off) { supportedModes += "off " }
if(cmd.heat) { supportedModes += "heat " }
if(cmd.auxiliaryemergencyHeat) { supportedModes += "emergency heat " }
if(cmd.cool) { supportedModes += "cool " }
if(cmd.auto) { supportedModes += "auto " }
if(cmd.energySaveHeat) { supportedModes += "energySaveHeat " }
state.supportedModes = supportedModes
}
def zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {
if (cmd.parameterNumber == 1){
if (cmd.configurationValue == [0, 0]){
log.debug("Current Mode is Off")
sendEvent(name: "thermostatMode", value: "off")
sendEvent(name: "thermostatOperatingState", value: "idle")
}
else if (cmd.configurationValue == [0, 1]){
log.debug("Current Mode is Heat")
sendEvent(name: "thermostatMode", value: "heat")
sendEvent(name: "thermostatOperatingState", value: "heating")
}
else if (cmd.configurationValue == [0, 2]){
log.debug("Current Mode is Cool")
}
else if (cmd.configurationValue == [0, 11]){
log.debug("Current Mode is Energy Save Heat")
sendEvent(name: "thermostatMode", value: "energySaveHeat")
sendEvent(name: "thermostatOperatingState", value: "energySaveHeat")
}
}
if (cmd.parameterNumber == 2){
if (cmd.configurationValue == [0, 0]){
log.debug("Temperature Sensor F - Floor mode: Regulation is based on the floor temperature sensor reading")
sendEvent(name: "tempSenseMode", value: "F")
}
else if (cmd.configurationValue == [0, 1]){
log.debug("Temperature Sensor A - Room temperature mode: Regulation is based on the measured room temperature using the internal sensor (Default)")
sendEvent(name: "tempSenseMode", value: "A")
}
else if (cmd.configurationValue == [0, 2]){
log.debug("Temperature Sensor AF - Room mode w/floor limitations: Regulation is based on internal room sensor but limited by the floor temperature sensor (included) ensuring that the floor temperature stays within the given limits (FLo/FHi")
sendEvent(name: "tempSenseMode", value: "AF")
}
else if (cmd.configurationValue == [0, 3]){
log.debug("Temperature Sensor 2 - Room temperature mode: Regulation is based on the measured room temperature using the external sensor")
sendEvent(name: "tempSenseMode", value: "A2")
}
else if (cmd.configurationValue == [0, 4]){
log.debug("Temperature Sensor P (Power regulator): Constant heating power is supplied to the floor. Power rating is selectable in 10% increments ( 0% - 100%)")
sendEvent(name: "tempSenseMode", value: "P")
}
else if (cmd.configurationValue == [0, 5]){
log.debug("Temperature Sensor FP - Floor mode with minimum power limitation: Regulation is based on the floor temperature sensor reading, but will always heat with a minimum power setting (PLo)")
sendEvent(name: "tempSenseMode", value: "FP")
}
}
if (cmd.parameterNumber == 3){
if (cmd.configurationValue == [0, 0]){
log.debug("Floor sensor type 10k ntc (Default)")
}
else if (cmd.configurationValue == [0, 1]){
log.debug("Floor sensor type 12k ntc")
}
else if (cmd.configurationValue == [0, 2]){
log.debug("Floor sensor type 15k ntc")
}
else if (cmd.configurationValue == [0, 3]){
log.debug("Floor sensor type 22k ntc")
}
else if (cmd.configurationValue == [0, 4]){
log.debug("Floor sensor type 33k ntc")
}
else if (cmd.configurationValue == [0, 5]){
log.debug("Floor sensor type 47k ntc")
}
}
if (cmd.parameterNumber == 4){
def val = cmd.configurationValue[1]
def diff = val / 10
def newHys = 0.2 + diff
log.debug("DIFF l. Temperature control Hysteresis is $newHys °C")
}
if (cmd.parameterNumber == 5){
def valX = cmd.configurationValue[0]
def valY = cmd.configurationValue[1]
def diff = binaryToDegrees(valX, valY)
//log.debug("the command is: $cmd")
log.debug("FLo: Floor min limit is $diff °C")
}
if (cmd.parameterNumber == 6){
def valX1 = cmd.configurationValue[0]
def valY1 = cmd.configurationValue[1]
def diff = binaryToDegrees(valX1, valY1)
// def val = cmd.configurationValue[1]
// def diff = val / 10
log.debug("FHi: Floor max limit is $diff °C")
}
if (cmd.parameterNumber == 7){
def valX = cmd.configurationValue[0]
def valY = cmd.configurationValue[1]
def diff = binaryToDegrees(valX, valY)
log.debug("ALo: Air min limit is $diff °C")
}
if (cmd.parameterNumber == 8){
def valX1 = cmd.configurationValue[0]
def valY1 = cmd.configurationValue[1]
def diff = binaryToDegrees(valX1, valY1)
log.debug("AHi: Air max limit is $diff °C")
}
if (cmd.parameterNumber == 9){
def val = cmd.configurationValue[1]
log.debug("PLo: Min temperature in Power Reg Mode is $val °C")
}
if (cmd.parameterNumber == 10){
def valX = cmd.configurationValue[0]
def valY = cmd.configurationValue[1]
def diff = binaryToDegrees(valX, valY)
log.debug("CO mode setpoint is $diff °C")
}
if (cmd.parameterNumber == 11){
def valX = cmd.configurationValue[0]
def valY = cmd.configurationValue[1]
def diff = binaryToDegrees(valX, valY)
log.debug("ECO mode setpoint is $diff °C")
sendEvent(name: "ecoheatingSetpoint", value: diff)
}
if (cmd.parameterNumber == 12){
def val = cmd.configurationValue[0]
def diff = val * 10
log.debug("P (Power regulator) is $diff %")
}
}
/*
def zwaveEvent(physicalgraph.zwave.commands.thermostatfanmodev3.ThermostatFanModeSupportedReport cmd) {
def supportedFanModes = ""
if(cmd.auto) { supportedFanModes += "fanAuto " }
if(cmd.low) { supportedFanModes += "fanOn " }
if(cmd.circulation) { supportedFanModes += "fanCirculate " }
state.supportedFanModes = supportedFanModes
}
*/
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
log.debug "Basic Zwave event received: $cmd.payload"
}
/*def zwaveEvent(physicalgraph.zwave.Command cmd) {
log.warn "Unexpected zwave command $cmd"
}
*/
// Command Implementations
def pressUp(){
log.debug("pressed Up")
def currTemp = device.latestValue("heatingSetpoint")
log.debug(" pressed up currently $currTemp")
def newTemp = currTemp + 0.5
log.debug(" pressed up new temp is $newTemp")
quickSetHeat(newTemp)
}
def pressDown(){
log.debug("pressed Down")
def currTemp = device.latestValue("heatingSetpoint")
def newTemp = currTemp - 0.5
quickSetHeat(newTemp)
}
/*
def quickSetHeat(upDown) {
log.debug("pressed")
def change = upDown
log.debug(change)
def latest = device.latestValue("heatingSetpoint")
if (change == 1) {
def newSetPoint = latest + 1
log.debug("New Set Point: $newSetPoint")
state.setPoint = newSetPoint
log.debug("New State Set Point: $state.setPoint")
setHeatingSetpoint(newSetPoint, 1000)
}
else if (change == 0) {
def newSetPoint = latest - 1
log.debug("New Set Point: $newSetPoint")
state.setPoint = newSetPoint
log.debug("New State Set Point: $state.setPoint")
setHeatingSetpoint(newSetPoint, 1000)
}
//setHeatingSetpoint(degrees, 1000)
// log.debug("Degrees at quicksetheat: $degrees")
}
*/
def quickSetHeat(degrees) {
setHeatingSetpoint(degrees, 1000)
}
def setHeatingSetpoint(degrees, delay = 30000) {
setHeatingSetpoint(degrees.toDouble(), delay)
}
def setHeatingSetpoint(Double degrees, Integer delay = 30000) {
log.trace "setHeatingSetpoint($degrees, $delay)"
def deviceScale = state.scale ?: 1
def deviceScaleString = deviceScale == 2 ? "C" : "F"
def locationScale = getTemperatureScale()
def p = (state.precision == null) ? 1 : state.precision
def convertedDegrees
//if (locationScale == "C" && deviceScaleString == "F") {
// convertedDegrees = celsiusToFahrenheit(degrees)
//} else if (locationScale == "F" && deviceScaleString == "C") {
convertedDegrees = fahrenheitToCelsius(degrees)
//} else {
convertedDegrees = degrees
//}
delayBetween([
zwave.thermostatSetpointV1.thermostatSetpointSet(setpointType: 1, scale: deviceScale, precision: p, scaledValue: convertedDegrees).format(),
zwave.thermostatSetpointV1.thermostatSetpointGet(setpointType: 1).format()
], delay)
}
def quickSetecoHeat(degrees) {
setecoHeatingSetpoint(degrees, 1000)
}
def setecoHeatingSetpoint(degrees, delay = 30000) {
setecoHeatingSetpoint(degrees.toDouble(), delay)
}
def setecoHeatingSetpoint(Double degrees, Integer delay = 30000) {
log.trace "setecoHeatingSetpoint($degrees, $delay)"
def deviceScale = state.scale ?: 1
def deviceScaleString = deviceScale == 2 ? "C" : "F"
def locationScale = getTemperatureScale()
def p = (state.precision == null) ? 1 : state.precision
def convertedDegrees
//if (locationScale == "C" && deviceScaleString == "F") {
// convertedDegrees = celsiusToFahrenheit(degrees)
//} else if (locationScale == "F" && deviceScaleString == "C") {
convertedDegrees = fahrenheitToCelsius(degrees)
//} else {
convertedDegrees = degrees
//}
delayBetween([
zwave.thermostatSetpointV1.thermostatSetpointSet(setpointType: 11, scale: deviceScale, precision: p, scaledValue: convertedDegrees).format(),
zwave.thermostatSetpointV1.thermostatSetpointGet(setpointType: 11).format()
], delay)
}
/*
def quickSetCool(degrees) {
setCoolingSetpoint(degrees, 1000)
}
def setCoolingSetpoint(degrees, delay = 30000) {
setCoolingSetpoint(degrees.toDouble(), delay)
}
def setCoolingSetpoint(Double degrees, Integer delay = 30000) {
log.trace "setCoolingSetpoint($degrees, $delay)"
def deviceScale = state.scale ?: 1
def deviceScaleString = deviceScale == 2 ? "C" : "F"
def locationScale = getTemperatureScale()
def p = (state.precision == null) ? 1 : state.precision
def convertedDegrees
if (locationScale == "C" && deviceScaleString == "F") {
convertedDegrees = celsiusToFahrenheit(degrees)
} else if (locationScale == "F" && deviceScaleString == "C") {
convertedDegrees = fahrenheitToCelsius(degrees)
} else {
convertedDegrees = degrees
}
delayBetween([
zwave.thermostatSetpointV1.thermostatSetpointSet(setpointType: 2, scale: deviceScale, precision: p, scaledValue: convertedDegrees).format(),
zwave.thermostatSetpointV1.thermostatSetpointGet(setpointType: 2).format()
], delay)
}
*/
def poll() {
delayBetween([
zwave.sensorMultilevelV5.sensorMultilevelGet().format(), // current temperature
zwave.thermostatSetpointV2.thermostatSetpointGet(setpointType: 1).format(),
zwave.thermostatSetpointV2.thermostatSetpointGet(setpointType: 2).format(),
zwave.thermostatModeV2.thermostatModeGet().format(),
zwave.configurationV2.configurationGet(parameterNumber: 1).format(),
zwave.configurationV2.configurationGet(parameterNumber: 2).format(),
zwave.configurationV2.configurationGet(parameterNumber: 3).format(),
zwave.configurationV2.configurationGet(parameterNumber: 4).format(),
zwave.configurationV2.configurationGet(parameterNumber: 5).format(),
zwave.configurationV2.configurationGet(parameterNumber: 6).format(),
zwave.configurationV2.configurationGet(parameterNumber: 7).format(),
zwave.configurationV2.configurationGet(parameterNumber: 8).format(),
zwave.configurationV2.configurationGet(parameterNumber: 9).format(),
zwave.configurationV2.configurationGet(parameterNumber: 10).format(),
zwave.configurationV2.configurationGet(parameterNumber: 11).format(),
zwave.configurationV2.configurationGet(parameterNumber: 12).format()
// zwave.basicV1.basicGet().format(),
// zwave.thermostatOperatingStateV2.thermostatOperatingStateGet().format()
], 650)
}
def configure() {
def floorMinY = 0
def floorMinX = 0
def floorMin = 0
if (FLo){
floorMin = FLo
if (floorMin <= 25.5){
floorMinX = 0
floorMinY = floorMin*10
}
else if (floorMin > 25.5){
floorMinX = 1
floorMinY = floorMin*10 - 256
}
}
def floorMax = 0
def floorMaxY = 0
def floorMaxX = 0
if (FHi){
floorMax = FHi
if (floorMax <= 25.5){
floorMaxX = 0
floorMaxY = floorMax*10
}
else if (floorMax > 25.5){
floorMaxX = 1
floorMaxY = floorMax*10 - 256
}
}
def AirMin = 0
def AirMinY = 0
def AirMinX = 0
if (ALo){
AirMin = ALo
if (AirMin <= 25.5){
AirMinX = 0
AirMinY = AirMin*10
}
else if (AirMin > 25.5){
AirMinX = 1
AirMinY = AirMin*10 - 256
}
}
def AirMax = 0
def AirMaxY = 0
def AirMaxX = 0
if (AHi){
AirMax = AHi
if (AirMax <= 25.5){
AirMaxX = 0
AirMaxY = AirMax*10
}
else if (AirMax > 25.5){
AirMaxX = 1
AirMaxY = AirMax*10 - 256
}
}
def tempSensorMode = ""
def tempModeParam = 1
if (tempSen){
tempSensorMode = tempSen
if (tempSensorMode == "F - Floor temperature mode"){
tempModeParam = 0
}
if (tempSensorMode == "A - Room temperature mode"){
tempModeParam = 1
}
if (tempSensorMode == "AF - Room mode w/floor limitations"){
tempModeParam = 2
}
if (tempSensorMode == "A2 - Room temperature mode (external)"){
tempModeParam = 3
}
if (tempSensorMode == "P - Power regulator mode"){
tempModeParam = 4
}
if (tempSensorMode == "FP - Floor mode with minimum power limitation"){
tempModeParam = 5
}
}
def floorSensor = ""
def floorSensParam = 0
if (sensorType){
floorSensor = sensorType
if (floorSensor == "10k ntc (Default)"){
floorSensParam = 0
}
if (floorSensor == "12k ntc"){
floorSensParam = 1
}
if (floorSensor == "15k ntc"){
floorSensParam = 2
}
if (floorSensor == "22k ntc"){
floorSensParam = 3
}
if (floorSensor == "33k ntc"){
floorSensParam = 4
}
if (floorSensor == "47k ntc"){
floorSensParam = 5
}
}
def powerLo = 0
if (PLo){
powerLo = PLo
}
def powerSet = 0
def powerSetPer = ""
if (PSet){
powerSetPer = PSet
if (powerSetPer == "0%"){
powerSet = 0
}
if (powerSetPer == "10%"){
powerSet = 1
}
if (powerSetPer == "20%"){
powerSet = 2
}
if (powerSetPer == "30%"){
powerSet = 3
log.debug("powerset 3")
}
if (powerSetPer == "40%"){
powerSet = 4
}
if (powerSetPer == "50%"){
powerSet = 5
}
if (powerSetPer == "60%"){
powerSet = 6
}
if (powerSetPer == "70%"){
powerSet = 7
}
if (powerSetPer == "80%"){
powerSet = 8
}
if (powerSetPer == "90%"){
powerSet = 9
}
if (powerSetPer == "100%"){
powerSet = 10
}
// DO LIKE LIST INSTEAD 0, 10, 20, 30 etc so no issues powerSetRound = Math.floor(powerSet)
// log.debug("floor: $powerSetRound")
}
delayBetween([
zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId]).format(),
zwave.configurationV2.configurationSet(configurationValue: [0, tempModeParam], parameterNumber: 2, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [0, floorSensParam], parameterNumber: 3, size: 2).format(),
// zwave.configurationV2.configurationSet(configurationValue: [0, 0], parameterNumber: 3, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [floorMinX, floorMinY], parameterNumber: 5, size: 2).format(),
//zwave.configurationV2.configurationSet(configurationValue: [0, 50], parameterNumber: 5, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [floorMaxX, floorMaxY], parameterNumber: 6, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [AirMinX, AirMinY], parameterNumber: 7, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [AirMaxX, AirMaxY], parameterNumber: 8, size: 2).format(),
zwave.configurationV2.configurationSet(configurationValue: [powerLo], parameterNumber: 9, size: 1).format(),
zwave.configurationV2.configurationSet(configurationValue: [powerSet], parameterNumber: 12, size: 1).format(),//zwave.configurationV2.configurationSet(configurationValue: [1, 144], parameterNumber: 6, size: 2).format(),