forked from claudegel/sinope-zha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thermostat.py
557 lines (495 loc) · 18.6 KB
/
thermostat.py
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
"""Module to handle quirks of the Sinopé Technologies thermostat.
Manufacturer specific cluster implements attributes to control displaying
of outdoor temperature, setting occupancy on/off and setting device time.
"""
import zigpy.profiles.zha as zha_p
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
Ota,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic, ElectricalMeasurement
from zigpy.zcl.clusters.hvac import Thermostat, UserInterface
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.smartenergy import Metering
from zigpy.zcl.foundation import Array
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.sinope import SINOPE, SINOPE_MANUFACTURER_CLUSTER_ID
class SinopeTechnologiesManufacturerCluster(CustomCluster):
"""SinopeTechnologiesManufacturerCluster manufacturer cluster."""
class KeypadLock(t.enum8):
"""keypad_lockout values."""
Unlocked = 0x00
Locked = 0x01
Partial_lock = 0x02
class Display(t.enum8):
"""config_2nd_display values."""
Auto = 0x00
Setpoint = 0x01
Outside_temperature = 0x02
class FloorMode(t.enum8):
"""air_floor_mode values."""
Air_by_floor = 0x01
Floor = 0x02
class AuxMode(t.enum8):
"""aux_output_mode values."""
Off = 0x00
On = 0x01
class PumpStatus(t.uint8_t):
"""Pump protection status."""
Off = 0x00
On = 0x01
class LimitStatus(t.uint8_t):
"""Floor limit status values."""
Ok = 0x00
Low_reached = 0x01
Max_reached = 0x02
Max_air_reached = 0x03
class SensorType(t.enum8):
"""temp_sensor_type values."""
Sensor_10k = 0x00
Sensor_12k = 0x01
class TimeFormat(t.enum8):
"""time_format values."""
Format_24h = 0x00
Format_12h = 0x01
class GfciStatus(t.enum8):
"""gfci_status values."""
Ok = 0x00
Error = 0x01
class SystemMode(t.enum8):
"""system mode values."""
Off = 0x00
Auto = 0x01
Cool = 0x03
Heat = 0x04
class PumpDuration(t.enum8):
"""Pump protection duration period values."""
T5 = 0x05
T10 = 0x0A
T15 = 0x0F
T20 = 0x14
T30 = 0x1E
T60 = 0x3C
class CycleLength(t.uint16_t):
""""Cycle length, 15 sec (15) or 15 min (900 sec)."""
Sec_15 = 0x000F
Min_15 = 0x0384
cluster_id = SINOPE_MANUFACTURER_CLUSTER_ID
name = "Sinopé Technologies Manufacturer specific"
ep_attribute = "sinope_manufacturer_specific"
attributes = {
0x0001: ("unknown_attr_0", t.Bool, True),
0x0002: ("keypad_lockout", KeypadLock, True),
0x0003: ("firmware_number", t.uint16_t, True),
0x0004: ("firmware_version", t.CharacterString, True),
0x0010: ("outdoor_temp", t.int16s, True),
0x0011: ("outdoor_temp_timeout", t.uint16_t, True),
0x0012: ("config_2nd_display", Display, True),
0x0020: ("secs_since_2k", t.uint32_t, True),
0x0070: ("current_load", t.bitmap8, True),
0x0071: ("eco_delta_setpoint", t.int8s, True),
0x0072: ("eco_max_pi_heating_demand", t.uint8_t, True),
0x0073: ("eco_safety_temperature_delta", t.uint8_t, True),
0x0080: ("unknown_attr_9", t.uint32_t, True),
0x0100: ("unknown_attr_2", t.uint8_t, True),
0x0101: ("unknown_attr_1", Array, True),
0x0102: ("unknown_attr_3", t.uint8_t, True),
0x0103: ("unknown_attr_7", Array, True),
0x0104: ("setpoint", t.int16s, True),
0x0105: ("air_floor_mode", FloorMode, True),
0x0106: ("aux_output_mode", AuxMode, True),
0x0107: ("floor_temperature", t.int16s, True),
0x0108: ("air_max_limit", t.int16s, True),
0x0109: ("floor_min_setpoint", t.int16s, True),
0x010A: ("floor_max_setpoint", t.int16s, True),
0x010B: ("floor_sensor_type_param", SensorType, True),
0x010C: ("floor_limit_status", LimitStatus, True),
0x010D: ("room_temperature", t.int16s, True),
0x0114: ("time_format", TimeFormat, True),
0x0115: ("gfci_status", GfciStatus, True),
0x0116: ("hvac_mode", SystemMode, True),
0x0117: ("unknown_attr_8", Array, True),
0x0118: ("aux_connected_load", t.uint16_t, True),
0x0119: ("connected_load", t.uint16_t, True),
0x0128: ("pump_protection_status", PumpStatus, True),
0x012A: ("pump_protection_duration", PumpDuration, True),
0x012B: ("current_setpoint", t.int16s, True),
0x012C: ("unknown_attr_4", Array, True),
0x012D: ("report_local_temperature", t.int16s, True),
0x0139: ("unknown_attr_10", t.int16s, True),
0x013B: ("unknown_attr_11", t.bitmap8, True),
0x0200: ("status", t.bitmap32, True),
0x0202: ("unknown_attr_6", t.enum8, True),
0x0281: ("cycle_length", CycleLength, True),
0x0283: ("unknown_attr_13", t.enum8, True),
0x0284: ("unknown_attr_14", t.uint16_t, True),
0x0285: ("unknown_attr_15", t.uint8_t, True),
0x0286: ("unknown_attr_16", t.uint8_t, True),
0xFFFD: ("cluster_revision", t.uint16_t, True),
}
class SinopeTechnologiesThermostatCluster(CustomCluster, Thermostat):
"""SinopeTechnologiesThermostatCluster custom cluster."""
class Occupancy(t.enum8):
"""Set_occupancy values."""
Away = 0x00
Home = 0x01
class Backlight(t.enum8):
"""Backlight_auto_dim_param values."""
On_demand = 0x00
Always_on = 0x01
Bedroom = 0x02
class CycleOutput(t.uint16_t):
"""Main and aux cycle period values."""
Sec_15 = 0x000F
Min_5 = 0x012C
Min_10 = 0x0258
Min_15 = 0x0384
Min_20 = 0x04B0
Min_25 = 0x05DC
Min_30 = 0x0708
Off = 0xFFFF
attributes = Thermostat.attributes.copy()
attributes.update(
{
0x0400: ("set_occupancy", Occupancy, True),
0x0401: ("main_cycle_output", CycleOutput, True),
0x0402: ("backlight_auto_dim_param", Backlight, True),
0x0404: ("aux_cycle_output", CycleOutput, True),
0x0421: ("unknown_attr_1", t.uint16_t, True),
0x0422: ("unknown_attr_2", t.uint16_t, True),
0x0423: ("unknown_attr_3", t.int16s, True),
0x0424: ("unknown_attr_4", t.int16s, True),
0x0425: ("unknown_attr_5", t.int16s, True),
0x0426: ("unknown_attr_6", t.int16s, True),
0x0427: ("unknown_attr_7", t.uint16_t, True),
0x0428: ("unknown_attr_8", t.uint16_t, True),
0x0429: ("unknown_attr_9", t.int16s, True),
0x0430: ("unknown_attr_10", t.int16s, True),
0x0431: ("unknown_attr_11", t.int16s, True),
0x0432: ("unknown_attr_12", t.int16s, True),
0x0433: ("unknown_attr_13", t.uint16_t, True),
0x0434: ("unknown_attr_14", t.uint16_t, True),
0x0435: ("unknown_attr_15", t.int16s, True),
0x0436: ("unknown_attr_16", t.uint16_t, True),
0x0439: ("unknown_attr_17", t.uint16_t, True),
0xFFFD: ("cluster_revision", t.uint16_t, True),
}
)
class SinopeTechnologiesElectricalMeasurementCluster(
CustomCluster, ElectricalMeasurement
):
"""SinopeTechnologiesElectricalMeasurementCluster custom cluster."""
attributes = ElectricalMeasurement.attributes.copy()
attributes.update(
{
0x0551: ("current_summation_delivered", t.uint32_t, True),
0x0552: ("aux_setpoint_min", t.uint32_t, True),
0x0553: ("aux_setpoint_max", t.uint32_t, True),
}
)
class SinopeTechnologiesThermostat(CustomDevice):
"""SinopeTechnologiesThermostat custom device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769
# device_version=0 input_clusters=[0, 3, 4, 5, 513, 516, 1026, 2820,
# 2821, 65281] output_clusters=[65281, 25]>
MODELS_INFO: [
(SINOPE, "TH1123ZB"),
(SINOPE, "TH1124ZB"),
(SINOPE, "TH1500ZB"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
ElectricalMeasurement.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, SINOPE_MANUFACTURER_CLUSTER_ID],
},
# <SimpleDescriptor endpoint=196 profile=49757 device_type=769
# device_version=0 input_clusters=[1] output_clusters=[]>
196: {
PROFILE_ID: 0xC25D,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [PowerConfiguration.cluster_id],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
SinopeTechnologiesElectricalMeasurementCluster,
SinopeTechnologiesThermostatCluster,
SinopeTechnologiesManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
},
196: {INPUT_CLUSTERS: [PowerConfiguration.cluster_id]},
}
}
class SinopeTH1400ZB(SinopeTechnologiesThermostat):
"""TH1400ZB thermostat."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=1
# input_clusters=[0, 3, 4, 5, 513, 516, 1026, 1794, 2821, 65281]
# output_clusters=[10, 65281, 25]>
MODELS_INFO: [(SINOPE, "TH1400ZB")],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
Diagnostic.cluster_id,
SinopeTechnologiesThermostatCluster,
SinopeTechnologiesManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
}
}
class SinopeTH1300ZB(SinopeTechnologiesThermostat):
"""TH1300ZB thermostat."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=1
# input_clusters=[0, 3, 4, 5, 513, 516, 1026, 1794, 2820, 2821, 65281]
# output_clusters=[10, 25, 65281]>
MODELS_INFO: [(SINOPE, "TH1300ZB")],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
Diagnostic.cluster_id,
SinopeTechnologiesElectricalMeasurementCluster,
SinopeTechnologiesThermostatCluster,
SinopeTechnologiesManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
}
}
class SinopeLineThermostats(SinopeTechnologiesThermostat):
"""TH1123ZB, TH1124ZB, TH1500ZB and OTH3600-GA-ZB thermostats."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=1
# input_clusters=[0, 3, 4, 5, 513, 516, 1026, 1794, 2820, 2821, 65281]
# output_clusters=[10, 25, 65281]>
MODELS_INFO: [
(SINOPE, "TH1123ZB"),
(SINOPE, "TH1124ZB"),
(SINOPE, "TH1500ZB"),
(SINOPE, "OTH3600-GA-ZB"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
Diagnostic.cluster_id,
SinopeTechnologiesElectricalMeasurementCluster,
SinopeTechnologiesThermostatCluster,
SinopeTechnologiesManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
}
}
}
class SinopeG2Thermostats(SinopeTechnologiesThermostat):
"""TH1123ZB-G2 and TH1124ZB-G2 thermostats."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=1
# input_clusters=[0, 3, 4, 5, 513, 516, 1026, 1794, 2820, 2821, 65281]
# output_clusters=[3, 10, 25]>
MODELS_INFO: [
(SINOPE, "TH1123ZB-G2"),
(SINOPE, "TH1124ZB-G2"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
UserInterface.cluster_id,
TemperatureMeasurement.cluster_id,
Metering.cluster_id,
Diagnostic.cluster_id,
SinopeTechnologiesElectricalMeasurementCluster,
SinopeTechnologiesThermostatCluster,
SinopeTechnologiesManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
}
}
}