9
9
from zigpy .zcl import foundation
10
10
11
11
from zhaquirks .tuya import (
12
+ TUYA_MCU_VERSION_REQ ,
13
+ TUYA_QUERY_DATA ,
12
14
TUYA_SET_TIME ,
13
15
TuyaPowerConfigurationCluster2AAA ,
14
16
TuyaTimePayload ,
@@ -32,6 +34,53 @@ class TuyaNousTempHumiAlarm(t.enum8):
32
34
Canceled = 0x02
33
35
34
36
37
+ class NoManufTimeTuyaMCUCluster (TuyaMCUCluster ):
38
+ """Tuya Manufacturer Cluster with set_time mod."""
39
+
40
+ set_time_offset = 1970
41
+ set_time_local_offset = 1970
42
+
43
+ # Deepcopy required to override 'set_time', without, it will revert
44
+ server_commands = copy .deepcopy (TuyaMCUCluster .server_commands )
45
+ server_commands .update (
46
+ {
47
+ TUYA_SET_TIME : foundation .ZCLCommandDef (
48
+ "set_time" ,
49
+ {"time" : TuyaTimePayload },
50
+ False ,
51
+ is_manufacturer_specific = False ,
52
+ ),
53
+ }
54
+ )
55
+
56
+
57
+ class RespondingTuyaMCUCluster (TuyaMCUCluster ):
58
+ """Tuya Manufacturer Cluster with mcu version response."""
59
+
60
+ def handle_mcu_version_response (
61
+ self , payload : TuyaMCUCluster .MCUVersion
62
+ ) -> foundation .Status :
63
+ """Handle MCU version response."""
64
+
65
+ self .create_catching_task (
66
+ super ().command (TUYA_MCU_VERSION_REQ , 2 , expect_reply = False )
67
+ )
68
+ self .create_catching_task (super ().command (TUYA_QUERY_DATA , expect_reply = False ))
69
+ super ().handle_mcu_version_response (payload )
70
+
71
+ server_commands = copy .deepcopy (TuyaMCUCluster .server_commands )
72
+ server_commands .update (
73
+ {
74
+ TUYA_MCU_VERSION_REQ : foundation .ZCLCommandDef (
75
+ "mcu_version_req" ,
76
+ {"data" : t .uint16_t },
77
+ True ,
78
+ is_manufacturer_specific = False ,
79
+ ),
80
+ }
81
+ )
82
+
83
+
35
84
(
36
85
TuyaQuirkBuilder ("_TZE200_bjawzodf" , "TS0601" )
37
86
.applies_to ("_TZE200_zl1kmjqx" , "TS0601" )
@@ -87,26 +136,6 @@ class TuyaNousTempHumiAlarm(t.enum8):
87
136
)
88
137
89
138
90
- class NoManufTimeTuyaMCUCluster (TuyaMCUCluster ):
91
- """Tuya Manufacturer Cluster with set_time mod."""
92
-
93
- set_time_offset = 1970
94
- set_time_local_offset = 1970
95
-
96
- # Deepcopy required to override 'set_time', without, it will revert
97
- server_commands = copy .deepcopy (TuyaMCUCluster .server_commands )
98
- server_commands .update (
99
- {
100
- TUYA_SET_TIME : foundation .ZCLCommandDef (
101
- "set_time" ,
102
- {"time" : TuyaTimePayload },
103
- False ,
104
- is_manufacturer_specific = False ,
105
- ),
106
- }
107
- )
108
-
109
-
110
139
# TH01Z - Temperature and humidity sensor with clock
111
140
(
112
141
TuyaQuirkBuilder ("_TZE200_lve3dvpy" , "TS0601" )
@@ -317,3 +346,19 @@ class NoManufTimeTuyaMCUCluster(TuyaMCUCluster):
317
346
.skip_configuration ()
318
347
.add_to_registry ()
319
348
)
349
+
350
+
351
+ (
352
+ TuyaQuirkBuilder ("_TZE204_upagmta9" , "TS0601" )
353
+ .tuya_temperature (dp_id = 1 , scale = 10 )
354
+ .tuya_humidity (dp_id = 2 )
355
+ .tuya_dp (
356
+ dp_id = 3 ,
357
+ ep_attribute = TuyaPowerConfigurationCluster2AAA .ep_attribute ,
358
+ attribute_name = "battery_percentage_remaining" ,
359
+ converter = lambda x : {0 : 50 , 1 : 100 , 2 : 200 }[x ],
360
+ )
361
+ .adds (TuyaPowerConfigurationCluster2AAA )
362
+ .skip_configuration ()
363
+ .add_to_registry (replacement_cluster = RespondingTuyaMCUCluster )
364
+ )
0 commit comments