zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
685 stars 638 forks source link

[BUG] Aqara T1 cube #2900

Open JoranHonig opened 6 months ago

JoranHonig commented 6 months ago

Bug description

It seems like various functions aren't working on my device.

Quirk: CubeCAGL02

What works:

what doesn't:

Device signature

Device signature ```json { "node_descriptor": "NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)", "endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x6f01", "input_clusters": [ "0x0000", "0x0001", "0x0003", "0x0012", "0x0019" ], "output_clusters": [ "0x0000", "0x0003", "0x0019" ] }, "2": { "profile_id": "0x0104", "device_type": "0x6f01", "input_clusters": [ "0x0012" ], "output_clusters": [ "0x0012" ] }, "3": { "profile_id": "0x0104", "device_type": "0x6f01", "input_clusters": [ "0x000c" ], "output_clusters": [ "0x000c" ] } }, "manufacturer": "LUMI", "model": "lumi.remote.cagl02", "class": "zhaquirks.xiaomi.aqara.cube_aqgl01.CubeCAGL02" } ```

Diagnostic information

No response

Logs

Logs ```python 2024-01-10 18:26:36.385 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(timestamp=datetime.datetime(2024, 1, 10, 17, 26, 36, 385239, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=, address=0xB84E), src_ep=2, dst=AddrModeAddress(addr_mode=, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=222, profile_id=260, cluster_id=18, data=Serialized[b'\x18|\nU\x00!\x02\x04'], tx_options=, radius=0, non_member_radius=0, lqi=212, rssi=-47) 2024-01-10 18:26:36.385 DEBUG (MainThread) [zigpy.zcl] [0xB84E:2:0x0012] Received ZCL frame: b'\x18|\nU\x00!\x02\x04' 2024-01-10 18:26:36.386 DEBUG (MainThread) [zigpy.zcl] [0xB84E:2:0x0012] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=, is_manufacturer_specific=0, direction=, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True), tsn=124, command_id=10, *direction=) 2024-01-10 18:26:36.386 DEBUG (MainThread) [zigpy.zcl] [0xB84E:2:0x0012] Decoded ZCL frame: MultistateInputCluster:Report_Attributes(attribute_reports=[Attribute(attrid=0x0055, value=TypeValue(type=uint16_t, value=1026))]) 2024-01-10 18:26:36.386 DEBUG (MainThread) [zigpy.zcl] [0xB84E:2:0x0012] Received command 0x0A (TSN 124): Report_Attributes(attribute_reports=[Attribute(attrid=0x0055, value=TypeValue(type=uint16_t, value=1026))]) 2024-01-10 18:26:36.386 DEBUG (MainThread) [zigpy.zcl] [0xB84E:2:0x0012] Attribute report received: present_value=1026 2024-01-10 18:26:36.390 DEBUG (MainThread) [zigpy.appdb] Error handling '_save_attribute' event with (54:ef:44:10:00:93:d3:7b, 2, 18, 0, None, datetime.datetime(2024, 1, 10, 17, 26, 36, 386962, tzinfo=datetime.timezone.utc)) params: NOT NULL constraint failed: attributes_cache_v12.value 2024-01-10 18:26:38.363 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(timestamp=datetime.datetime(2024, 1, 10, 17, 26, 38, 363286, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=, address=0xB84E), src_ep=2, dst=AddrModeAddress(addr_mode=, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=223, profile_id=260, cluster_id=64704, data=Serialized[b'\x18}\nI\x01 \x02'], tx_options=, radius=0, non_member_radius=0, lqi=244, rssi=-39) 2024-01-10 18:26:38.363 DEBUG (MainThread) [zigpy.device] [0xb84e] Ignoring message on unknown cluster 64704 for endpoint > ```

Additional information

No response

JoranHonig commented 6 months ago

It seems like the following values need updating:

SLIDE_1_VALUE = 1024  # 256  # aqara skyside
SLIDE_2_VALUE = 1027  # 257  # aqara facing me 90 right
SLIDE_3_VALUE = 1025  # 258  # aqara facing me upside down
SLIDE_4_VALUE = 1029  # 259  # aqara tableside
SLIDE_5_VALUE = 1026  # 260  # aqara facing me 90 left
SLIDE_6_VALUE = 1028  # 261  # aqara facing me upright

edit2:

It seems to me like the signature has to be incomplete, with a missing XiaomiAqaraE1Cluster that's used for auxillary.

I have no clue how to make this work tho, and why 0xfcc0 is not part of the reported signature

edit 3:

The error in the logs is triggered by: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/xiaomi/aqara/cube_aqgl01.py#L184

This line needs to be indented.

The trigger of the bug is when the action for a value is not known.