Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Avatto thermostats (Tuya) #3748

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions tests/test_tuya_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,84 @@

from tests.common import ClusterListener
import zhaquirks
from zhaquirks.tuya import TUYA_MCU_VERSION_RSP
from zhaquirks.tuya.mcu import TuyaMCUCluster

zhaquirks.setup()

ZCL_TUYA_VERSION_RSP = b"\x09\x06\x11\x01\x6d\x82"
ZCL_TUYA_SET_TIME = b"\x09\x12\x24\x0d\x00"


@pytest.mark.parametrize(
"msg,attr,value",
"manuf,msg,attr,value",
[
(
"_TZE204_p3lqqy2r",
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
Thermostat.AttributeDefs.system_mode,
Thermostat.SystemMode.Heat,
), # Set to heat, dp 1
(
"_TZE204_p3lqqy2r",
b"\t\x16\x02\x00\t\x18\x02\x00\x04\x00\x00\x00\x18",
Thermostat.AttributeDefs.local_temperature,
2400,
), # Current temp 24, dp 24
(
"_TZE204_p3lqqy2r",
b"\t\x15\x02\x00\x08\x10\x02\x00\x04\x00\x00\x00\x19",
Thermostat.AttributeDefs.occupied_heating_setpoint,
2500,
), # Setpoint to 25, dp 16
(
"_TZE204_p3lqqy2r",
b"\t\x17\x02\x00\n\x1c\x02\x00\x04\x00\x00\x00\x00",
Thermostat.AttributeDefs.local_temperature_calibration,
0,
), # Local calibration to 0, dp 28
(
"_TZE204_p3lqqy2r",
b"\t\x1c\x02\x00\x0fh\x01\x00\x01\x01",
Thermostat.AttributeDefs.running_state,
Thermostat.RunningState.Heat_State_On,
), # Running state, dp 104
(
"_TZE204_p3lqqy2r",
b"\t\x1d\x02\x00\x10k\x02\x00\x04\x00\x00\x00\x1b",
Thermostat.AttributeDefs.max_heat_setpoint_limit,
2700,
), # Max heat set point, dp 107
(
"_TZE204_lzriup1j",
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
Thermostat.AttributeDefs.system_mode,
Thermostat.SystemMode.Heat,
), # Set to heat, dp 1
(
"_TZE200_viy9ihs7",
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
Thermostat.AttributeDefs.system_mode,
Thermostat.SystemMode.Heat,
), # Set to heat, dp 1
(
"_TZE204_xnbkhhdr",
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
Thermostat.AttributeDefs.system_mode,
Thermostat.SystemMode.Heat,
), # Set to heat, dp 1
(
"_TZE284_xnbkhhdr",
b"\t\x13\x02\x00\x06\x01\x01\x00\x01\x01",
Thermostat.AttributeDefs.system_mode,
Thermostat.SystemMode.Heat,
), # Set to heat, dp 1
],
)
async def test_handle_get_data(zigpy_device_from_v2_quirk, msg, attr, value):
async def test_handle_get_data(zigpy_device_from_v2_quirk, manuf, msg, attr, value):
"""Test handle_get_data for multiple attributes."""

quirked = zigpy_device_from_v2_quirk("_TZE204_p3lqqy2r", "TS0601")
quirked = zigpy_device_from_v2_quirk(manuf, "TS0601")
ep = quirked.endpoints[1]

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

assert ep.thermostat.get(attr.id) == value


async def test_tuya_no_mcu_version(zigpy_device_from_v2_quirk):
"""Test lack of TUYA_MCU_VERSION_RSP messages."""

tuya_device = zigpy_device_from_v2_quirk("_TZE284_xnbkhhdr", "TS0601")

tuya_cluster = tuya_device.endpoints[1].tuya_manufacturer
cluster_listener = ClusterListener(tuya_cluster)

assert len(cluster_listener.attribute_updates) == 0

# simulate a TUYA_MCU_VERSION_RSP message
hdr, args = tuya_cluster.deserialize(ZCL_TUYA_VERSION_RSP)
assert hdr.command_id == TUYA_MCU_VERSION_RSP

tuya_cluster.handle_message(hdr, args)
assert len(cluster_listener.attribute_updates) == 0
217 changes: 0 additions & 217 deletions zhaquirks/tuya/ts0601_thermostat.py

This file was deleted.

Loading
Loading