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
753 stars 693 forks source link

[Device Support Request] TS0601 Thermostat _TZE200_cpmgn2cf #1439

Closed RamiRihawi closed 2 years ago

RamiRihawi commented 2 years ago

Is your feature request related to a problem? Please describe. This version of the device is not compatible with ZHA yet.

Describe the solution you'd like The device is added without any entities. I want to be able to control at least the close and open functionality of the device

**Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen.

Please find below device signature in code block and Logs while adding the device

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4098, 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=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": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_cpmgn2cf",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}

LOGS:

[0x0000:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_rsp: [<Status.SUCCESS: 0>] [0x0000:zdo] No handler for ZDO request:ZDOCmd.Mgmt_Permit_Joining_rsp([<Status.SUCCESS: 0>]) New device 0x7728 (90:35:ea:ff:fe:2a:87:81) joined the network [0x7728] Scheduling initialization Received frame on uninitialized device from ep 0 to ep 0, cluster 19: b'\x85(w\x81\x87\xfe\xff\xea5\x90\x80' [0x7728:zdo] ZDO request ZDOCmd.Device_annce: [0x7728, 90:35:ea:ff:fe:2a:87:81, 128] Tries remaining: 3 [0x7728] Requesting 'Node Descriptor' Tries remaining: 2 [0x7728] Extending timeout for 0x31 request Received frame on uninitialized device from ep 0 to ep 0, cluster 32770: b'1\x00(w\x02@\x80\x02\x10RR\x00\x00,R\x00\x00' [0x7728] Got Node Descriptor: NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4098, 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=True, is_full_function_device=False, is_mains_powered=False, is_receiver_on_when_idle=False, is_router=False, is_security_capable=False) [0x7728] Discovering endpoints Tries remaining: 3 [0x7728] Extending timeout for 0x32 request Received frame on uninitialized device from ep 0 to ep 0, cluster 32773: b'2\x00(w\x01\x01' [0x7728] Discovered endpoints: [1] [0x7728] Initializing endpoints [<Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>] [0x7728:1] Discovering endpoint information Tries remaining: 3 [0x7728] Extending timeout for 0x33 request Received frame on uninitialized device from ep 0 to ep 0, cluster 32772: b'3\x00(w\x14\x01\x04\x01Q\x00\x01\x04\x00\x00\x04\x00\x05\x00\x00\xef\x02\x19\x00\n\x00' [0x7728:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=81, device_version=1, input_clusters=[0, 4, 5, 61184], output_clusters=[25, 10]) Unknown cluster 61184 [0x7728] Extending timeout for 0x34 request [0x7728:1:0x0000] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=52 command_id=Command.Read_Attributes_rsp> [0x7728] Read model 'TS0601' and manufacturer '_TZE200_cpmgn2cf' from <Endpoint id=1 in=[basic:0x0000, groups:0x0004, scenes:0x0005, None:0xEF00] out=[ota:0x0019, time:0x000A] status=<Status.ZDO_INIT: 1>> [0x7728] Discovered basic device information for Device is initialized Checking quirks for _TZE200_cpmgn2cf TS0601 (90:35:ea:ff:fe:2a:87:81) Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'> Fail because endpoint list mismatch: {232, 230} {1} Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'> Fail because endpoint list mismatch: {232, 230} {1} Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'> Fail because device_type mismatch on at least one endpoint Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'> Fail because device_type mismatch on at least one endpoint Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'> Fail because device_type mismatch on at least one endpoint Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'> Fail because endpoint list mismatch: {11, 13} {1} Considering <class 'bellows.zigbee.application.EZSPCoordinator'> Fail because device_type mismatch on at least one endpoint 'sensor' component -> 'RSSISensor' using ['basic'] 'sensor' component -> 'LQISensor' using ['basic'] device - 0x7728:90:35:ea:ff:fe:2a:87:81 entering async_device_initialized - is_new_join: True device - 0x7728:90:35:ea:ff:fe:2a:87:81 has joined the ZHA zigbee network 0x7728: started configuration 0x7728:ZDO: 'async_configure' stage succeeded [0x7728:1:0x0000]: finished channel configuration [0x7728:1:0x0019]: finished channel configuration Error handling '_save_attribute' event with (90:35:ea:ff:fe:2a:87:81, 1, 0, 4, '_TZE200_cpmgn2cf') params: FOREIGN KEY constraint failed [0x7728:1:0x0000]: 'async_configure' stage succeeded [0x7728:1:0x0019]: 'async_configure' stage succeeded Error handling '_save_attribute' event with (90:35:ea:ff:fe:2a:87:81, 1, 0, 5, 'TS0601') params: FOREIGN KEY constraint failed 0x7728: completed configuration 0x7728: stored in registry: ZhaDeviceEntry(name='_TZE200_cpmgn2cf TS0601', ieee='90:35:ea:ff:fe:2a:87:81', last_seen=1647975891.6932693) 0x7728: started initialization 0x7728:ZDO: 'async_initialize' stage succeeded [0x7728:1:0x0000]: initializing channel: from_cache: False [0x7728:1:0x0000]: finished channel initialization [0x7728:1:0x0019]: initializing channel: from_cache: False [0x7728:1:0x0019]: finished channel initialization [0x7728:1:0x0000]: 'async_initialize' stage succeeded [0x7728:1:0x0019]: 'async_initialize' stage succeeded 0x7728: power source: Battery or Unknown 0x7728: completed initialization 0x82F5:1:0x0b04: failed to get attributes '['active_power', 'rms_current', 'rms_voltage']' on 'electrical_measurement' cluster: [0x7728:1:0x000a] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=54 command_id=Command.Read_Attributes> [0x7728:1:0x000a] ZCL request 0x0000: [[7]] [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=55 command_id=36> [0x7728:1:0xef00] Unknown cluster-specific command 36 [0x7728:1:0xef00] ZCL request 0x0024: b'\x00\x00' [0x7728:1:0xef00] No handler for cluster command 36 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=56 command_id=36> [0x7728:1:0xef00] Unknown cluster-specific command 36 [0x7728:1:0xef00] ZCL request 0x0024: b'\x00\x17' [0x7728:1:0xef00] No handler for cluster command 36 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=57 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x004f\x02\x00\x04\x00\x00\x00\x05' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=58 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x005g\x02\x00\x04\x00\x00\x00#' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=59 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x006\x02\x02\x00\x04\x00\x00\x00\x9b' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=60 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x007\x03\x02\x00\x04\x00\x00\x00\xd7' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=61 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x008\x04\x04\x00\x01\x06' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=62 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x009\x07\x01\x00\x01\x00' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=63 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00:\r\x05\x00\x01\x00' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=64 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00;,\x02\x00\x04\xff\xff\xff\xf6' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=65 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00<h\x00\x00\x03\x00\x05\n' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=66 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00=i\x02\x00\x04\x00\x00\x01,' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=67 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00>j\x04\x00\x01\x00' [0x7728:1:0xef00] No handler for cluster command 1

0x4875:1:0x0b04 ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=53 command_id=Command.Read_Attributes_rsp> 0xeb04:1:0x0b04 ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=55 command_id=Command.Read_Attributes_rsp> 0x8237:1:0x0b04 ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=56 command_id=Command.Read_Attributes_rsp> [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=68 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00?k\x02\x00\x04\x00\x00\x00\x14' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=69 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00@l\x02\x00\x04\x00\x00\x00\x0f' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=70 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00Am\x02\x00\x04\x00\x00\x00\x00' [0x7728:1:0xef00] No handler for cluster command 1 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=71 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00Bn\x01\x00\x01\x00' [0x7728:1:0xef00] No handler for cluster command 1 0x82F5:1:0x0b04: failed to get attributes '['active_power', 'rms_current', 'rms_voltage']' on 'electrical_measurement' cluster: [0x53B7:1:0x0500]: Updated alarm state: 0 [0x7728:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=72 command_id=1> [0x7728:1:0xef00] Unknown cluster-specific command 1 [0x7728:1:0xef00] ZCL request 0x0001: b'\x00Co\x04\x00\x01\x00' [0x7728:1:0xef00] No handler for cluster command 1

Additional context https://www.aliexpress.com/item/4001065119510.html?spm=a2g0o.order_list.0.0.21ef1802WETkFk

MattWestb commented 2 years ago

Its one "clasic" quirk for this device but your new device ID is not added but can being done in the quirk and also in ZHA for getting all functions if it. Add your ID on one new line here: https://github.com/zigpy/zha-device-handlers/blob/039a31f1ca15821e800bdb347eb47fdb02455f31/zhaquirks/tuya/ts0601_trv.py#L1422-L1429 And also in ZHA here https://github.com/home-assistant/core/blob/78a41022ade7f070db6ed5c7678a0ba1171b72e6/homeassistant/components/zha/climate.py#L595-L608 Its also one working local quirk with more function but its not merged by you can installing it as local quirk: https://github.com/zigpy/zha-device-handlers/pull/1192 (its also need the adding in ZHA climate.py).

Using local quirk is described here https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274. The ZHA climate.py need being edited in the HA container https://github.com/zigpy/zha-device-handlers/discussions/693#discussion-1237451.

MattWestb commented 2 years ago

Patched climate.py for ZHA container and ts0601_trv.py (classic) and and (neo) ts0601_trv_moes.py. Dont use both at the same time then it can making problems. ts0601_trv.zip

Copy the climate.py to /usr/src/homeassistant/homeassistant/components/zha/climate.py in the HA container with command cp /usr/src/homeassistant/homeassistant/components/zha/climate.py /config/climate.py inside the HA container after have copy the climate.py to the HA confing directory. The quirk you can configure local quirk and copy one of them in the new folder and restarting HA and it shall being loaded is all is OK.

RamiRihawi commented 2 years ago

Thank you very much for your help, One thing though, i do not have HA installed as a container, but as a full system on RPi4. That means i cannot use cp commands.

I already created "custom_zha_quirks" folder, and added the path to configuration file. What shall i do for climate.py?

Do you have another suggestion?

MattWestb commented 2 years ago

If you is running on one real OS is the path different but i dont remember it but the end is the same then you is finding the local ha files in your system. Use google for command finding files in your system.

RamiRihawi commented 2 years ago

All is working now, Thank you a lot.

MattWestb commented 2 years ago

Witch version did you trying ? I like making one PR for adding it in the system permanent so not need doing all one more time then updating HA.

RamiRihawi commented 2 years ago

From the Zip folder you sent me i used first "ts0601_trv.py" which reviled only three entities. and i added the climate.py to the config folder of HA.

Then i tried the second one "ts0601_trv_moes.py" after removing the first one. now i have all entities listed.

MattWestb commented 2 years ago

Great !!! The first one have more or less the same functions but not in ZHA GUI and must being made with cluster commands and attribute.

I making one PR for adding it in the classic one and then you can using it then HA is getting it in the release and can using the new one as custom quirk is you like until we is getting it merged.

Reproduktor commented 2 years ago

Hi all, I get this problem when launching HA with this quirk (HA 2022.11):

TypeError: `manufacturer_attributes` is deprecated. Copy the parent class's `attributes` dictionary and update it with your manufacturer-specific `attributes`. Make sure to specify that it is manufacturer-specific through the appropriate constructor or tuple!

Any ideas?

Frogowitsch commented 1 year ago

Same problem here as Reproduktor. Is the quirk not compatible with newer HA versions or what can be the problem ?

Frogowitsch commented 1 year ago

I get a lot of functions from this tvr, but what i need is force valve open and close. This one does not show up. Any idea what the problem can be ? All other functions are there.

bennipi1287 commented 1 year ago

I get a lot of functions from this tvr, but what i need is force valve open and close. This one does not show up. Any idea what the problem can be ? All other functions are there.

How did you fix the problem?

Theo16 commented 1 year ago

I have HA with ZHA lasted version and my valve _TZE200_cpmgn2cf TS0601 does not show entities like valve position, window open etc. like in zigbee2mqtt. Is it possible to have this entities in ZHA?

pepelillo commented 1 year ago

Same here, same device same behaviour.