1
1
"""Tuya TS0601 Thermostat."""
2
2
3
+ from zigpy .quirks .v2 import BinarySensorDeviceClass , EntityType
3
4
from zigpy .quirks .v2 .homeassistant import (
4
5
UnitOfElectricCurrent ,
5
6
UnitOfElectricPotential ,
17
18
18
19
19
20
class RegulatorPeriod (t .enum8 ):
20
- """Tuya Regulator Period enum."""
21
+ """Tuya regulator period enum."""
21
22
22
23
FifteenMin = 0x00
23
24
ThirtyMin = 0x01
@@ -27,28 +28,71 @@ class RegulatorPeriod(t.enum8):
27
28
28
29
29
30
class ThermostatMode (t .enum8 ):
30
- """Tuya Thermostat mode."""
31
+ """Tuya thermostat mode."""
31
32
32
33
Regulator = 0x00
33
34
Thermostat = 0x01
34
35
35
36
36
- class PresetMode (t .enum8 ):
37
- """Tuya PresetMode enum."""
37
+ class PresetModeV01 (t .enum8 ):
38
+ """Tuya preset mode v01 enum."""
38
39
39
40
Manual = 0x00
40
41
Home = 0x01
41
42
Away = 0x02
42
43
43
44
45
+ class PresetModeV02 (t .enum8 ):
46
+ """Tuya preset mode v02 enum."""
47
+
48
+ Manual = 0x00
49
+ Auto = 0x01
50
+ Temporary_Manual = 0x02
51
+
52
+
53
+ class PresetModeV03 (t .enum8 ):
54
+ """Tuya preset mode v03 enum."""
55
+
56
+ Auto = 0x00
57
+ Manual = 0x01
58
+ Temporary_Manual = 0x02
59
+
60
+
44
61
class SensorMode (t .enum8 ):
45
- """Tuya SensorMode enum."""
62
+ """Tuya sensor mode enum."""
46
63
47
64
Air = 0x00
48
65
Floor = 0x01
49
66
Both = 0x02
50
67
51
68
69
+ class BacklightMode (t .enum8 ):
70
+ """Tuya backlight mode enum."""
71
+
72
+ Off = 0x00
73
+ Low = 0x01
74
+ Medium = 0x02
75
+ High = 0x03
76
+
77
+
78
+ class WorkingDayV01 (t .enum8 ):
79
+ """Tuya Working day v01 enum."""
80
+
81
+ Disabled = 0x00
82
+ Six_One = 0x01
83
+ Five_Two = 0x02
84
+ Seven = 0x03
85
+
86
+
87
+ class WorkingDayV02 (t .enum8 ):
88
+ """Tuya Working day v02 enum."""
89
+
90
+ Disabled = 0x00
91
+ Five_Two = 0x01
92
+ Six_One = 0x02
93
+ Seven = 0x03
94
+
95
+
52
96
class TuyaThermostat (Thermostat , TuyaAttributesCluster ):
53
97
"""Tuya local thermostat cluster."""
54
98
@@ -82,7 +126,7 @@ def __init__(self, *args, **kwargs):
82
126
.tuya_enum (
83
127
dp_id = 2 ,
84
128
attribute_name = "preset_mode" ,
85
- enum_class = PresetMode ,
129
+ enum_class = PresetModeV01 ,
86
130
translation_key = "preset_mode" ,
87
131
fallback_name = "Preset mode" ,
88
132
)
@@ -215,3 +259,166 @@ def __init__(self, *args, **kwargs):
215
259
.skip_configuration ()
216
260
.add_to_registry ()
217
261
)
262
+
263
+
264
+ # Tuya ZWT198/ZWT100-BH Avatto wall thermostat
265
+ base_avatto_quirk = (
266
+ TuyaQuirkBuilder ()
267
+ .tuya_dp (
268
+ dp_id = 1 ,
269
+ ep_attribute = TuyaThermostat .ep_attribute ,
270
+ attribute_name = TuyaThermostat .AttributeDefs .system_mode .name ,
271
+ converter = lambda x : 0x00 if not x else 0x04 ,
272
+ dp_converter = lambda x : x != 0x00 ,
273
+ )
274
+ .tuya_dp (
275
+ dp_id = 2 ,
276
+ ep_attribute = TuyaThermostat .ep_attribute ,
277
+ attribute_name = TuyaThermostat .AttributeDefs .occupied_heating_setpoint .name ,
278
+ converter = lambda x : x * 10 ,
279
+ dp_converter = lambda x : x // 10 ,
280
+ )
281
+ .tuya_dp (
282
+ dp_id = 3 ,
283
+ ep_attribute = TuyaThermostat .ep_attribute ,
284
+ attribute_name = TuyaThermostat .AttributeDefs .local_temperature .name ,
285
+ converter = lambda x : x * 10 ,
286
+ )
287
+ .tuya_switch (
288
+ dp_id = 9 ,
289
+ attribute_name = "child_lock" ,
290
+ translation_key = "child_lock" ,
291
+ fallback_name = "Child lock" ,
292
+ )
293
+ .tuya_binary_sensor (
294
+ dp_id = 11 ,
295
+ attribute_name = "fault_alarm" ,
296
+ entity_type = EntityType .STANDARD ,
297
+ device_class = BinarySensorDeviceClass .PROBLEM ,
298
+ translation_key = "fault_alarm" ,
299
+ fallback_name = "Fault alarm" ,
300
+ )
301
+ .tuya_dp (
302
+ dp_id = 15 ,
303
+ ep_attribute = TuyaThermostat .ep_attribute ,
304
+ attribute_name = TuyaThermostat .AttributeDefs .max_heat_setpoint_limit .name ,
305
+ converter = lambda x : x * 10 ,
306
+ dp_converter = lambda x : x // 10 ,
307
+ )
308
+ .tuya_dp (
309
+ dp_id = 19 ,
310
+ ep_attribute = TuyaThermostat .ep_attribute ,
311
+ attribute_name = TuyaThermostat .AttributeDefs .local_temperature_calibration .name ,
312
+ converter = lambda x : x * 10 ,
313
+ dp_converter = lambda x : x // 10 ,
314
+ )
315
+ .tuya_dp (
316
+ dp_id = 101 ,
317
+ ep_attribute = TuyaThermostat .ep_attribute ,
318
+ attribute_name = TuyaThermostat .AttributeDefs .running_state .name ,
319
+ converter = lambda x : 0x00 if not x else 0x01 ,
320
+ )
321
+ .tuya_switch (
322
+ dp_id = 102 ,
323
+ attribute_name = "frost_protection" ,
324
+ translation_key = "frost_protection" ,
325
+ fallback_name = "Frost protection" ,
326
+ )
327
+ .tuya_switch (
328
+ dp_id = 103 ,
329
+ attribute_name = "factory_reset" ,
330
+ translation_key = "factory_reset" ,
331
+ fallback_name = "Factory reset" ,
332
+ )
333
+ .tuya_enum (
334
+ dp_id = 106 ,
335
+ attribute_name = "temperature_sensor_select" ,
336
+ enum_class = SensorMode ,
337
+ translation_key = "sensor_mode" ,
338
+ fallback_name = "Sensor mode" ,
339
+ )
340
+ .tuya_number (
341
+ dp_id = 107 ,
342
+ attribute_name = "deadzone_temperature" ,
343
+ type = t .uint16_t ,
344
+ unit = UnitOfTemperature .CELSIUS ,
345
+ min_value = 0.1 ,
346
+ max_value = 10 ,
347
+ step = 0.1 ,
348
+ translation_key = "deadzone_temperature" ,
349
+ fallback_name = "Deadzone temperature" ,
350
+ )
351
+ # 109 ZWT198 schedule, skipped
352
+ .tuya_enum (
353
+ dp_id = 110 ,
354
+ attribute_name = "backlight_mode" ,
355
+ enum_class = BacklightMode ,
356
+ translation_key = "backlight_mode" ,
357
+ fallback_name = "Backlight mode" ,
358
+ )
359
+ .adds (TuyaThermostat )
360
+ .skip_configuration ()
361
+ )
362
+
363
+
364
+ (
365
+ base_avatto_quirk .clone ()
366
+ .applies_to ("_TZE204_lzriup1j" , "TS0601" )
367
+ .tuya_enum (
368
+ dp_id = 4 ,
369
+ attribute_name = "preset_mode" ,
370
+ enum_class = PresetModeV02 ,
371
+ translation_key = "preset_mode" ,
372
+ fallback_name = "Preset mode" ,
373
+ )
374
+ .tuya_enum (
375
+ dp_id = 104 ,
376
+ attribute_name = "working_day" ,
377
+ enum_class = WorkingDayV02 ,
378
+ translation_key = "working_day" ,
379
+ fallback_name = "Working day" ,
380
+ )
381
+ .add_to_registry ()
382
+ )
383
+
384
+ (
385
+ base_avatto_quirk .clone ()
386
+ .applies_to ("_TZE200_viy9ihs7" , "TS0601" )
387
+ .tuya_enum (
388
+ dp_id = 4 ,
389
+ attribute_name = "preset_mode" ,
390
+ enum_class = PresetModeV03 ,
391
+ translation_key = "preset_mode" ,
392
+ fallback_name = "Preset mode" ,
393
+ )
394
+ .tuya_enum (
395
+ dp_id = 104 ,
396
+ attribute_name = "working_day" ,
397
+ enum_class = WorkingDayV01 ,
398
+ translation_key = "working_day" ,
399
+ fallback_name = "Working day" ,
400
+ )
401
+ .add_to_registry ()
402
+ )
403
+
404
+
405
+ (
406
+ base_avatto_quirk .clone ()
407
+ .applies_to ("_TZE204_xnbkhhdr" , "TS0601" )
408
+ .applies_to ("_TZE284_xnbkhhdr" , "TS0601" )
409
+ .tuya_enum (
410
+ dp_id = 4 ,
411
+ attribute_name = "preset_mode" ,
412
+ enum_class = PresetModeV03 ,
413
+ translation_key = "preset_mode" ,
414
+ fallback_name = "Preset mode" ,
415
+ )
416
+ .tuya_enum (
417
+ dp_id = 104 ,
418
+ attribute_name = "working_day" ,
419
+ enum_class = WorkingDayV02 ,
420
+ translation_key = "working_day" ,
421
+ fallback_name = "Working day" ,
422
+ )
423
+ .add_to_registry ()
424
+ )
0 commit comments