Skip to content

Commit 160d900

Browse files
authored
Add Avatto thermostats (Tuya) (#3748)
1 parent e95eac6 commit 160d900

File tree

3 files changed

+506
-220
lines changed

3 files changed

+506
-220
lines changed

tests/test_tuya_thermostat.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,84 @@
66

77
from tests.common import ClusterListener
88
import zhaquirks
9+
from zhaquirks.tuya import TUYA_MCU_VERSION_RSP
910
from zhaquirks.tuya.mcu import TuyaMCUCluster
1011

1112
zhaquirks.setup()
1213

14+
ZCL_TUYA_VERSION_RSP = b"\x09\x06\x11\x01\x6d\x82"
15+
ZCL_TUYA_SET_TIME = b"\x09\x12\x24\x0d\x00"
16+
1317

1418
@pytest.mark.parametrize(
15-
"msg,attr,value",
19+
"manuf,msg,attr,value",
1620
[
1721
(
22+
"_TZE204_p3lqqy2r",
1823
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
1924
Thermostat.AttributeDefs.system_mode,
2025
Thermostat.SystemMode.Heat,
2126
), # Set to heat, dp 1
2227
(
28+
"_TZE204_p3lqqy2r",
2329
b"\t\x16\x02\x00\t\x18\x02\x00\x04\x00\x00\x00\x18",
2430
Thermostat.AttributeDefs.local_temperature,
2531
2400,
2632
), # Current temp 24, dp 24
2733
(
34+
"_TZE204_p3lqqy2r",
2835
b"\t\x15\x02\x00\x08\x10\x02\x00\x04\x00\x00\x00\x19",
2936
Thermostat.AttributeDefs.occupied_heating_setpoint,
3037
2500,
3138
), # Setpoint to 25, dp 16
3239
(
40+
"_TZE204_p3lqqy2r",
3341
b"\t\x17\x02\x00\n\x1c\x02\x00\x04\x00\x00\x00\x00",
3442
Thermostat.AttributeDefs.local_temperature_calibration,
3543
0,
3644
), # Local calibration to 0, dp 28
3745
(
46+
"_TZE204_p3lqqy2r",
3847
b"\t\x1c\x02\x00\x0fh\x01\x00\x01\x01",
3948
Thermostat.AttributeDefs.running_state,
4049
Thermostat.RunningState.Heat_State_On,
4150
), # Running state, dp 104
4251
(
52+
"_TZE204_p3lqqy2r",
4353
b"\t\x1d\x02\x00\x10k\x02\x00\x04\x00\x00\x00\x1b",
4454
Thermostat.AttributeDefs.max_heat_setpoint_limit,
4555
2700,
4656
), # Max heat set point, dp 107
57+
(
58+
"_TZE204_lzriup1j",
59+
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
60+
Thermostat.AttributeDefs.system_mode,
61+
Thermostat.SystemMode.Heat,
62+
), # Set to heat, dp 1
63+
(
64+
"_TZE200_viy9ihs7",
65+
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
66+
Thermostat.AttributeDefs.system_mode,
67+
Thermostat.SystemMode.Heat,
68+
), # Set to heat, dp 1
69+
(
70+
"_TZE204_xnbkhhdr",
71+
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
72+
Thermostat.AttributeDefs.system_mode,
73+
Thermostat.SystemMode.Heat,
74+
), # Set to heat, dp 1
75+
(
76+
"_TZE284_xnbkhhdr",
77+
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
78+
Thermostat.AttributeDefs.system_mode,
79+
Thermostat.SystemMode.Heat,
80+
), # Set to heat, dp 1
4781
],
4882
)
49-
async def test_handle_get_data(zigpy_device_from_v2_quirk, msg, attr, value):
83+
async def test_handle_get_data(zigpy_device_from_v2_quirk, manuf, msg, attr, value):
5084
"""Test handle_get_data for multiple attributes."""
5185

52-
quirked = zigpy_device_from_v2_quirk("_TZE204_p3lqqy2r", "TS0601")
86+
quirked = zigpy_device_from_v2_quirk(manuf, "TS0601")
5387
ep = quirked.endpoints[1]
5488

5589
assert ep.tuya_manufacturer is not None
@@ -69,3 +103,21 @@ async def test_handle_get_data(zigpy_device_from_v2_quirk, msg, attr, value):
69103
assert thermostat_listener.attribute_updates[0][1] == value
70104

71105
assert ep.thermostat.get(attr.id) == value
106+
107+
108+
async def test_tuya_no_mcu_version(zigpy_device_from_v2_quirk):
109+
"""Test lack of TUYA_MCU_VERSION_RSP messages."""
110+
111+
tuya_device = zigpy_device_from_v2_quirk("_TZE284_xnbkhhdr", "TS0601")
112+
113+
tuya_cluster = tuya_device.endpoints[1].tuya_manufacturer
114+
cluster_listener = ClusterListener(tuya_cluster)
115+
116+
assert len(cluster_listener.attribute_updates) == 0
117+
118+
# simulate a TUYA_MCU_VERSION_RSP message
119+
hdr, args = tuya_cluster.deserialize(ZCL_TUYA_VERSION_RSP)
120+
assert hdr.command_id == TUYA_MCU_VERSION_RSP
121+
122+
tuya_cluster.handle_message(hdr, args)
123+
assert len(cluster_listener.attribute_updates) == 0

zhaquirks/tuya/ts0601_thermostat.py

Lines changed: 0 additions & 217 deletions
This file was deleted.

0 commit comments

Comments
 (0)