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
721 stars 670 forks source link

[Device Support Request] TS0601 by _TZE200_khx7nnka (light sensor) #2014

Closed neuquenfr closed 1 year ago

neuquenfr commented 1 year ago

Is your feature request related to a problem? Please describe. The only entities returned are: LQI (ok), RSSI (unknown) and the information "Event are fired" each time I pair it. No way to measure light, which is its purpose.

Describe the solution you'd like Could this community please provide us with a quirk that makes this device work properly with HA (OS) 2022.12.6 and ZHA/Sonoff Zigbee 3.0 USB Dongle? Thank you!

```yaml { "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=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=, *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)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0051", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0xef00" ], "out_clusters": [ "0x000a", "0x0019" ] }, "242": { "profile_id": 41440, "device_type": "0x0061", "in_clusters": [], "out_clusters": [ "0x0021" ] } }, "manufacturer": "_TZE200_khx7nnka", "model": "TS0601", "class": "zigpy.device.Device" } ```
Diagnostic information ```yaml { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.12.6", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Europe/Madrid", "os_name": "Linux", "os_version": "5.15.76-v8", "supervisor": "2022.11.2", "host_os": "Home Assistant OS 9.4", "docker_version": "20.10.19", "chassis": "embedded", "run_as_root": true }, "custom_components": { "google_geocode": { "version": "0.1.9", "requirements": [] }, "hacs": { "version": "1.28.4", "requirements": [ "aiogithubapi>=22.2.4" ] }, "alexa_media": { "version": "4.3.2", "requirements": [ "alexapy==1.26.4", "packaging>=20.3", "wrapt>=1.12.1" ] }, "smartir": { "version": "1.17.6", "requirements": [ "aiofiles==0.6.0" ] }, "watchman": { "version": "0.5.1", "requirements": [ "prettytable==3.0.0" ] }, "tapo_control": { "version": "4.1.3", "requirements": [ "pytapo==2.5", "onvif-zeep-async==1.2.0" ] } }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zha", "requirements": [ "bellows==0.34.5", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.89", "zigpy-deconz==0.19.2", "zigpy==0.52.3", "zigpy-xbee==0.16.2", "zigpy-zigate==0.10.3", "zigpy-znp==0.9.2" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" } ], "dependencies": [ "file_upload" ], "after_dependencies": [ "onboarding", "usb", "zeroconf" ], "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp" ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 54767, "manufacturer": "_TZE200_khx7nnka", "model": "TS0601", "name": "_TZE200_khx7nnka TS0601", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "manufacturer_code": 4417, "power_source": "Mains", "lqi": 105, "rssi": null, "last_seen": "2022-12-17T18:06:03", "available": true, "device_type": "Router", "signature": { "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=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=, *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)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0051", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0xef00" ], "out_clusters": [ "0x000a", "0x0019" ] }, "242": { "profile_id": 41440, "device_type": "0x0061", "in_clusters": [], "out_clusters": [ "0x0021" ] } } }, "active_coordinator": false, "entities": [ { "entity_id": "sensor.tze200_khx7nnka_ts0601_rssi", "name": "_TZE200_khx7nnka TS0601" }, { "entity_id": "sensor.tze200_khx7nnka_ts0601_lqi", "name": "_TZE200_khx7nnka TS0601" } ], "neighbors": [], "routes": [], "endpoint_names": [ { "name": "SMART_PLUG" }, { "name": "unknown 97 device_type of 0xa1e0 profile id" } ], "user_given_name": "SensorLuz", "device_reg_id": "bcf470faa308d7ab2781eeb7bba0e070", "area_id": "sin_asignar", "cluster_details": { "1": { "device_type": { "name": "SMART_PLUG", "id": 81 }, "profile_id": 260, "in_clusters": { "0x0004": { "endpoint_attribute": "groups", "attributes": {}, "unsupported_attributes": {} }, "0x0005": { "endpoint_attribute": "scenes", "attributes": {}, "unsupported_attributes": {} }, "0xef00": { "endpoint_attribute": null, "attributes": {}, "unsupported_attributes": {} }, "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0000": { "attribute_name": "zcl_version", "value": 3 }, "0x0001": { "attribute_name": "app_version", "value": 70 }, "0x0002": { "attribute_name": "stack_version", "value": 0 }, "0x0003": { "attribute_name": "hw_version", "value": 1 }, "0x0004": { "attribute_name": "manufacturer", "value": "_TZE200_khx7nnka" }, "0x0005": { "attribute_name": "model", "value": "TS0601" }, "0x0006": { "attribute_name": "date_code", "value": "" }, "0x0007": { "attribute_name": "power_source", "value": 1 }, "0xfffd": { "attribute_name": "cluster_revision", "value": 2 }, "0xfffe": { "attribute_name": "attr_reporting_status", "value": 0 } }, "unsupported_attributes": { "0x4000": { "attribute_name": "sw_build_id" }, "0x000d": { "attribute_name": "serial_number" }, "0x0008": { "attribute_name": "generic_device_class" }, "0x0009": { "attribute_name": "generic_device_type" }, "0x000a": { "attribute_name": "product_code" }, "0x000b": { "attribute_name": "product_url" }, "0x000c": { "attribute_name": "manufacturer_version_details" }, "0x000e": { "attribute_name": "product_label" }, "0x0010": { "attribute_name": "location_desc" }, "0x0011": { "attribute_name": "physical_env" }, "0x0012": { "attribute_name": "device_enabled" }, "0x0013": { "attribute_name": "alarm_mask" } } } }, "out_clusters": { "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} }, "0x000a": { "endpoint_attribute": "time", "attributes": {}, "unsupported_attributes": {} } } }, "242": { "device_type": { "name": "unknown", "id": 97 }, "profile_id": 41440, "in_clusters": {}, "out_clusters": { "0x0021": { "endpoint_attribute": "green_power", "attributes": {}, "unsupported_attributes": {} } } } } } } ```
Additional logs ``` Paste any additional debug logs here. Don't remove the extra line breaks outside the ``` marks. ```

Additional context image

URL of the product on Aliexpress: https://www.aliexpress.com/item/1005004095233195.html?spm=a2g0o.productlist.main.1.5c9casUkasUkTV&algo_pvid=ae555c11-2f6e-4f03-b524-494017be0553&algo_exp_id=ae555c11-2f6e-4f03-b524-494017be0553-0&pdp_ext_f=%7B%22sku_id%22%3A%2212000028017055693%22%7D&pdp_npi=2%40dis%21EUR%2115.76%214.35%21%21%21%21%21%402100b20d16713006786068965d0745%2112000028017055693%21sea&curPageLogUid=Kqct4PelnXdI

javicalle commented 1 year ago

I would try to add it to the TuyaIlluminance quirk: https://github.com/zigpy/zha-device-handlers/blob/954745eaf47b205f99534e34e11679b8853d8878/zhaquirks/tuya/ts0601_illuminance.py#L70

It will be something like:

        MODELS_INFO: [
            ("_TZE200_khx7nnka", "TS0601"),
            ("_TZE200_yi4jtqq1", "TS0601"),
        ],

There is a good guide for enabling your local quirk: https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274

neuquenfr commented 1 year ago

@javicalle , this worked at first attempt. Thank you so much for your help!

javicalle commented 1 year ago

If the quirk is working for your device, do you mind create a PR and add it to the library. You can do it editing the file from the web browser: https://github.com/zigpy/zha-device-handlers/blob/954745eaf47b205f99534e34e11679b8853d8878/zhaquirks/tuya/ts0601_illuminance.py#L70

Just follow the indications. This way others users would use the device thanks to you.

neuquenfr commented 1 year ago

@javicalle , I am totally new to contributing in Github and have passed hours reading/testing how to place a PR. Since I could not modify the original file (which is logical) and I did not understand most of the github vocabulary, I found a way to edit (probably a copy of) the file, then submit the result to Github (to where? I don't know). Maybe the procedure I followed was OK, but I doubt it. Sorry for that. The only modification I placed, leading to the device working, was to add up a line with ("_TZE200_khx7nnka", "TS0601"), as you recommended. Here is a copy of what is displayed on my desktop screen. I hope this helps the community. image

javicalle commented 1 year ago

Hi @neuquenfr you have done almost all the job. Thanks for trying so hard.

Your submit must have gone to your project fork:

And you have a banch patch-1 branch here:

Probably, when you go to your fork you will see a banner asking for create a PR to the master. Just push the button and follow the instructions.

neuquenfr commented 1 year ago

Honestly, @javicalle , I didn't see "one" green button, but several of them, leading me to the next one. I hope this worked, otherwise I'm sorry to be a nuisance for this so helpful community and hope I didn't mess up too much. Feel free to tell me what I should do to make things get back to normal. Thanks!

javicalle commented 1 year ago

@neuquenfr it haven't work as expected, but don't worry it can be messy if you are not familiar.

I have created the PR with your changes.

Once again, thanks for your job.

neuquenfr commented 1 year ago

Thank YOU, @javicalle !

alexanderwwagner commented 7 months ago

I have the same problem like @neuquenfr described in this issue with a actual Homeassistant version: Core 2024.1.5. What could be the problem?

It should be the same device... maybe a newer version? https://www.amazon.de/dp/B0CDVKY1TR?psc=1&ref=ppx_yo2ov_dt_b_product_details

AkazaRenn commented 4 months ago

Update: starts working after restarting Home Assistant

Me too here, the version shows the same as OP but no functional entities are returned. Reconfigure details shows this:

image

Sheridan commented 1 month ago
"tuyaDataPoints":
{
  "64": [{"name": "unknown", "type": "raw"}],
  "2": [{"name": "illuminance", "type": "value"}],
  "1": [{"name": "illuminanceType", "type": "enum"}]
},
"illuminanceType": {"enum": ["unknown", "unknown", "overload?"]}