1
1
"""Map from manufacturer to standard clusters for thermostatic valves."""
2
2
3
+ from typing import Any
4
+
3
5
from zigpy .profiles import zha
4
6
from zigpy .quirks .v2 .homeassistant import PERCENTAGE , UnitOfTemperature
5
7
from zigpy .quirks .v2 .homeassistant .binary_sensor import BinarySensorDeviceClass
@@ -79,6 +81,27 @@ def __init__(self, *args, **kwargs):
79
81
)
80
82
81
83
84
+ class TuyaThermostatV2NoSchedule (TuyaThermostatV2 ):
85
+ """Ensures schedule is disabled on system_mode change."""
86
+
87
+ async def write_attributes (
88
+ self ,
89
+ attributes : dict [str | int , Any ],
90
+ manufacturer : int | None = None ,
91
+ ** kwargs ,
92
+ ) -> list :
93
+ """Catch attribute writes for system_mode and set schedule to off."""
94
+ results = await super ().write_attributes (attributes , manufacturer )
95
+ if (
96
+ Thermostat .AttributeDefs .system_mode .id in attributes
97
+ or Thermostat .AttributeDefs .system_mode .name in attributes
98
+ ):
99
+ tuya_cluster = self .endpoint .tuya_manufacturer
100
+ await tuya_cluster .write_attributes ({"schedule_enable" : False })
101
+
102
+ return results
103
+
104
+
82
105
(
83
106
TuyaQuirkBuilder ("_TYST11_KGbxAXL2" , "GbxAXL2" )
84
107
.applies_to ("_TYST11_c88teujp" , "88teujp" )
@@ -103,8 +126,8 @@ def __init__(self, *args, **kwargs):
103
126
.replaces_endpoint (1 , device_type = zha .DeviceType .THERMOSTAT )
104
127
.tuya_dp (
105
128
dp_id = 3 ,
106
- ep_attribute = TuyaThermostatV2 .ep_attribute ,
107
- attribute_name = TuyaThermostatV2 .AttributeDefs .running_state .name ,
129
+ ep_attribute = TuyaThermostatV2NoSchedule .ep_attribute ,
130
+ attribute_name = TuyaThermostatV2NoSchedule .AttributeDefs .running_state .name ,
108
131
converter = lambda x : RunningState .Heat_State_On if x else RunningState .Idle ,
109
132
)
110
133
.tuya_switch (
@@ -121,8 +144,8 @@ def __init__(self, *args, **kwargs):
121
144
)
122
145
.tuya_number (
123
146
dp_id = 27 ,
124
- attribute_name = TuyaThermostatV2 .AttributeDefs .local_temperature_calibration .name ,
125
- type = t .int32s ,
147
+ attribute_name = TuyaThermostatV2NoSchedule .AttributeDefs .local_temperature_calibration .name ,
148
+ type = t .uint32_t ,
126
149
min_value = - 6 ,
127
150
max_value = 6 ,
128
151
unit = UnitOfTemperature .CELSIUS ,
@@ -138,8 +161,8 @@ def __init__(self, *args, **kwargs):
138
161
)
139
162
.tuya_dp (
140
163
dp_id = 101 ,
141
- ep_attribute = TuyaThermostatV2 .ep_attribute ,
142
- attribute_name = TuyaThermostatV2 .AttributeDefs .system_mode .name ,
164
+ ep_attribute = TuyaThermostatV2NoSchedule .ep_attribute ,
165
+ attribute_name = TuyaThermostatV2NoSchedule .AttributeDefs .system_mode .name ,
143
166
converter = lambda x : {
144
167
True : Thermostat .SystemMode .Heat ,
145
168
False : Thermostat .SystemMode .Off ,
@@ -151,18 +174,18 @@ def __init__(self, *args, **kwargs):
151
174
)
152
175
.tuya_dp (
153
176
dp_id = 102 ,
154
- ep_attribute = TuyaThermostatV2 .ep_attribute ,
155
- attribute_name = TuyaThermostatV2 .AttributeDefs .local_temperature .name ,
177
+ ep_attribute = TuyaThermostatV2NoSchedule .ep_attribute ,
178
+ attribute_name = TuyaThermostatV2NoSchedule .AttributeDefs .local_temperature .name ,
156
179
converter = lambda x : x * 10 ,
157
180
)
158
181
.tuya_dp (
159
182
dp_id = 103 ,
160
- ep_attribute = TuyaThermostatV2 .ep_attribute ,
161
- attribute_name = TuyaThermostatV2 .AttributeDefs .occupied_heating_setpoint .name ,
183
+ ep_attribute = TuyaThermostatV2NoSchedule .ep_attribute ,
184
+ attribute_name = TuyaThermostatV2NoSchedule .AttributeDefs .occupied_heating_setpoint .name ,
162
185
converter = lambda x : x * 10 ,
163
186
dp_converter = lambda x : x // 10 ,
164
187
)
165
- .adds (TuyaThermostatV2 )
188
+ .adds (TuyaThermostatV2NoSchedule )
166
189
.tuya_sensor (
167
190
dp_id = 104 ,
168
191
attribute_name = "valve_position" ,
0 commit comments