|
1 | 1 | """Tests for Tuya Sensor quirks."""
|
2 | 2 |
|
3 |
| -from unittest import mock |
4 |
| - |
5 | 3 | import pytest
|
6 | 4 | from zigpy.zcl import foundation
|
7 | 5 | from zigpy.zcl.clusters.general import Basic, PowerConfiguration
|
8 | 6 | from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
|
9 | 7 |
|
10 |
| -from tests.common import wait_for_zigpy_tasks |
11 | 8 | import zhaquirks
|
12 |
| -from zhaquirks.tuya import TUYA_MCU_VERSION_RSP, TuyaLocalCluster |
| 9 | +from zhaquirks.tuya import TuyaLocalCluster |
13 | 10 | from zhaquirks.tuya.mcu import TuyaMCUCluster
|
14 |
| -from zhaquirks.tuya.tuya_sensor import RespondingTuyaMCUCluster |
15 | 11 |
|
16 | 12 | # Temp DP 1, Humidity DP 2, Battery DP 3
|
17 | 13 | TUYA_TEMP01_HUM02_BAT03 = b"\x09\xe0\x02\x0b\x33\x01\x02\x00\x04\x00\x00\x00\xfd\x02\x02\x00\x04\x00\x00\x00\x47\x03\x02\x00\x04\x00\x00\x00\x01"
|
|
49 | 45 | ("_TZE200_ydrdfkim", "TS0601", 100, 10, False),
|
50 | 46 | ("_TZE284_locansqn", "TS0601", 100, 10, False),
|
51 | 47 | ("_TZE200_vvmbj46n", "TS0601", 100, 10, True),
|
52 |
| - ("_TZE204_upagmta9", "TS0601", 100, 10, False), |
53 | 48 | ],
|
54 | 49 | )
|
55 | 50 | async def test_handle_get_data(
|
@@ -113,6 +108,7 @@ async def test_handle_get_data(
|
113 | 108 | ("_TZE204_yjjdcqsq", "TS0601", 100, 10, TUYA_TEMP01_HUM02_BAT04),
|
114 | 109 | ("_TZE204_ksz749x8", "TS0601", 100, 10, TUYA_TEMP01_HUM02_BAT04),
|
115 | 110 | ("_TZE204_upagmta9", "TS0601", 100, 10, TUYA_TEMP01_HUM02_BAT03),
|
| 111 | + ("_TZE204_upagmta9", "TS0601", 100, 10, TUYA_TEMP01_HUM02_BAT03), |
116 | 112 | ],
|
117 | 113 | )
|
118 | 114 | async def test_handle_get_data_enum_batt(
|
@@ -174,32 +170,3 @@ def test_valid_attributes(zigpy_device_from_v2_quirk):
|
174 | 170 | assert {temperature_attr_id} == temperature_cluster._VALID_ATTRIBUTES
|
175 | 171 | assert {humidity_attr_id} == humidity_cluster._VALID_ATTRIBUTES
|
176 | 172 | assert {power_attr_id} == power_config_cluster._VALID_ATTRIBUTES
|
177 |
| - |
178 |
| - |
179 |
| -async def test_tuya_version(zigpy_device_from_v2_quirk): |
180 |
| - """Test TUYA_MCU_VERSION_RSP messages, ensure response.""" |
181 |
| - |
182 |
| - quirked = zigpy_device_from_v2_quirk("_TZE204_upagmta9", "TS0601") |
183 |
| - ep = quirked.endpoints[1] |
184 |
| - |
185 |
| - tuya_cluster = ep.tuya_manufacturer |
186 |
| - |
187 |
| - assert ep.tuya_manufacturer is not None |
188 |
| - assert isinstance(ep.tuya_manufacturer, TuyaMCUCluster) |
189 |
| - assert isinstance(ep.tuya_manufacturer, RespondingTuyaMCUCluster) |
190 |
| - |
191 |
| - # simulate a TUYA_MCU_VERSION_RSP message |
192 |
| - hdr, args = tuya_cluster.deserialize(ZCL_TUYA_VERSION_RSP) |
193 |
| - assert hdr.command_id == TUYA_MCU_VERSION_RSP |
194 |
| - |
195 |
| - with mock.patch.object( |
196 |
| - ep.tuya_manufacturer._endpoint, |
197 |
| - "request", |
198 |
| - return_value=foundation.Status.SUCCESS, |
199 |
| - ) as m1: |
200 |
| - ep.tuya_manufacturer.handle_message(hdr, args) |
201 |
| - await wait_for_zigpy_tasks() |
202 |
| - |
203 |
| - res_hdr = foundation.ZCLHeader.deserialize(m1.await_args[1]["data"]) |
204 |
| - assert not res_hdr[0].manufacturer |
205 |
| - assert not res_hdr[0].frame_control.is_manufacturer_specific |
0 commit comments