|
32 | 32 |
|
33 | 33 | import zhaquirks
|
34 | 34 | from zhaquirks.const import (
|
| 35 | + BUTTON_1, |
| 36 | + BUTTON_2, |
35 | 37 | DEVICE_TYPE,
|
36 | 38 | ENDPOINTS,
|
37 | 39 | INPUT_CLUSTERS,
|
@@ -1609,31 +1611,6 @@ async def test_xiaomi_e1_roller_commands_1(zigpy_device_from_quirk, command, val
|
1609 | 1611 | assert multistate_cluster._write_attributes.call_args[0][0][0].value.value == value
|
1610 | 1612 |
|
1611 | 1613 |
|
1612 |
| -@pytest.mark.parametrize( |
1613 |
| - "quirk", |
1614 |
| - (zhaquirks.xiaomi.aqara.switch_acn047.AqaraT2Relay,), |
1615 |
| -) |
1616 |
| -async def test_aqara_t2_relay(zigpy_device_from_quirk, quirk): |
1617 |
| - """Test Aqara T2 relay.""" |
1618 |
| - |
1619 |
| - device = zigpy_device_from_quirk(quirk) |
1620 |
| - mi_cluster = device.endpoints[1].multistate_input |
1621 |
| - mi_listener = ClusterListener(mi_cluster) |
1622 |
| - |
1623 |
| - mi_cluster.update_attribute(MultistateInput.AttributeDefs.present_value.id, 1) |
1624 |
| - assert len(mi_listener.attribute_updates) == 1 |
1625 |
| - assert mi_listener.attribute_updates[0][0] == 0 |
1626 |
| - assert mi_listener.attribute_updates[0][1] == "single" |
1627 |
| - |
1628 |
| - mi_cluster.update_attribute(MultistateInput.AttributeDefs.state_text.id, "foo") |
1629 |
| - assert len(mi_listener.attribute_updates) == 2 |
1630 |
| - assert ( |
1631 |
| - mi_listener.attribute_updates[1][0] |
1632 |
| - == MultistateInput.AttributeDefs.state_text.id |
1633 |
| - ) |
1634 |
| - assert mi_listener.attribute_updates[1][1] == "foo" |
1635 |
| - |
1636 |
| - |
1637 | 1614 | @pytest.mark.parametrize(
|
1638 | 1615 | "command, value",
|
1639 | 1616 | [
|
@@ -1664,6 +1641,30 @@ async def test_xiaomi_e1_roller_commands_2(zigpy_device_from_quirk, command, val
|
1664 | 1641 | )
|
1665 | 1642 |
|
1666 | 1643 |
|
| 1644 | +@pytest.mark.parametrize("endpoint", [(1), (2)]) |
| 1645 | +async def test_aqara_t2_relay(zigpy_device_from_quirk, endpoint): |
| 1646 | + """Test Aqara T2 relay.""" |
| 1647 | + |
| 1648 | + device = zigpy_device_from_quirk(zhaquirks.xiaomi.aqara.switch_acn047.AqaraT2Relay) |
| 1649 | + mi_cluster = device.endpoints[endpoint].multistate_input |
| 1650 | + mi_listener = ClusterListener(mi_cluster) |
| 1651 | + |
| 1652 | + buttons = {1: BUTTON_1, 2: BUTTON_2} |
| 1653 | + |
| 1654 | + mi_cluster.update_attribute(MultistateInput.AttributeDefs.present_value.id, 1) |
| 1655 | + assert len(mi_listener.attribute_updates) == 1 |
| 1656 | + assert mi_listener.attribute_updates[0][0] == 0 |
| 1657 | + assert mi_listener.attribute_updates[0][1] == buttons[endpoint] |
| 1658 | + |
| 1659 | + mi_cluster.update_attribute(MultistateInput.AttributeDefs.state_text.id, "foo") |
| 1660 | + assert len(mi_listener.attribute_updates) == 2 |
| 1661 | + assert ( |
| 1662 | + mi_listener.attribute_updates[1][0] |
| 1663 | + == MultistateInput.AttributeDefs.state_text.id |
| 1664 | + ) |
| 1665 | + assert mi_listener.attribute_updates[1][1] == "foo" |
| 1666 | + |
| 1667 | + |
1667 | 1668 | def test_aqara_acn003_signature_match(assert_signature_matches_quirk):
|
1668 | 1669 | signature = {
|
1669 | 1670 | "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4447, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
|
|
0 commit comments