ZHA Fails after custom quirks added

I’m trying to get Zigbee working using ZHA on Hassio running on a Home Assistant Blue (ODROID). I’m using a CC2531 USB stick. This works fine and picks up my Moes TRV but I need quirks to get data/control from that device.

When I try adding quirks using the custom_quirks_path option in configuration.yaml (/config/zhaquirks/) then I get this error:

Logger: homeassistant.config_entries
Source: zhaquirks/bosch/motion.py:12
First occurred: 9:47:23 (1 occurrences)
Last logged: 9:47:23

Error setting up entry TI CC2531 USB CDC, s/n: __0X00124B001CCDFB8C - Texas Instruments for zha
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 293, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File “/usr/src/homeassistant/homeassistant/components/zha/init.py”, line 99, in async_setup_entry
setup_quirks(config)
File “/usr/local/lib/python3.8/site-packages/zhaquirks/init.py”, line 403, in setup
importer.find_module(modname).load_module(modname)
File “”, line 462, in _check_name_wrapper
File “”, line 962, in load_module
File “”, line 787, in load_module
File “”, line 265, in _load_module_shim
File “”, line 702, in _load
File “”, line 671, in _load_unlocked
File “”, line 783, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/zhaquirks/bosch/motion.py”, line 12, in
from …const import (
ValueError: attempted relative import beyond top-level package

Appreciate any pointers as I am stumped.

If “attempted relative import beyond top-level package” is not clear for you, please show the quirk source.

I googled the error message so understand roughly what it means but can’t understand why it would be doing it. I copied the zhaquirks folder from here: GitHub - zigpy/zha-device-handlers and placed it in the location noted above. Not added anything custom.

custom_quirks_path is specifically for, well, custom quirks.
The github you mention is what is already included in HA.

What you have to do is create a quirk module there, with, e.g., that content: zha-device-handlers/zhaquirks/echostar at dev · zigpy/zha-device-handlers · GitHub

OK - thank you. That makes sense and closes this issue for me. Though it opens up another one - why the TRV then isn’t properly recognised if the relevant quirk is already included. Same model seems to have worked for other people with that quirk, if not perfectly (ZHA - ZigPy - Thermostatic valve TS0601 doesn't work - #5 by cyberium)

I’ll do some more digging and try to understand a bit more.

It would be easier if you stated your issue.
The post you mention is about installing a more recent version of the quirks for battery… 6 months ago.

Also post the device signature from ZHA:

It’s the most recent post I could find about this device. I’m a long time HA user but brand new to Zigbee. My whole system runs on ESPHome so I’m only just getting my head around even terminology. Appreciate you taking the time to respond.

Issue is that the device is recognised by ZHA and added to the network but without any functionality that I can see. I can’t see any data coming from it/way to control it (assuming it should create entities?)

Here’s the signature:

{
“node_descriptor”: “NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)”,
“endpoints”: {
“1”: {
“profile_id”: 260,
“device_type”: “0x0051”,
“in_clusters”: [
“0x0000”,
“0x0004”,
“0x0005”,
“0xef00”
],
“out_clusters”: [
“0x000a”,
“0x0019”
]
}
},
“manufacturer”: “_TZE200_b6wax7g0”,
“model”: “TS0601”,
“class”: “zigpy.device.Device”
}

Ok, I’m getting this. Added in the signature ("_TZE200_b6wax7g0", “TS0601”) to a version of valve.py stored in my custom quirks folder and now have some entities. Not perfect yet but I’m starting to understand.

Will keep playing.

Yep.
I suppose that’s what you did, but have to put ("_TZE200_b6wax7g0", "TS0601"),after:

            ("_TZE200_ckud7u2l", "TS0601"),
            ("_TZE200_ywdxldoj", "TS0601"),
            ("_TZE200_cwnjrr72", "TS0601"),

If you confirm it works, I’ll do a quick PR to zigpy so that other users don’t stumble on this.

Yep - that’s exactly what I did. I’m still getting my head around clusters so can’t confirm full functionality yet but will once I’ve played some more.

OK - I’m not convinced everything works perfectly yet but I can read and set temperature through the thermostat card so that’s good enough for me for now. Worth doing the PR for other people as it will get them over the initial hump at least.

Thanks again for your help.

Hi

I am having the same issue as bookofthefutureTom Cheesewright. I have HA setup and am using the ZHA integration to connect my zigbee devices to HA, which I have been successful at doing so far.

I recently bought a new TRV (TRV 02) which ZHA recognizes as the following:
Model: TS0601
Manufacturer: _TZE200_b6wax7g0

I already have a very similar TRV (TRV 1) setup in HA and working perfectly as shown in the picture below:

TRV 1 is working as it should and exposes all relevant entities to allow control of the TRV via HA:

However, TRV 02 (_TZE200_b6wax7g0) does not expose any entities and therefore cannot be controlled via HA:

I was hoping someone can help me setup TRV 02 so it exposes the entities as TRV 1 so I can control it via HA.

I would like to add I am new to HS and only been using it for approx 6 months so can do the basics like edit config files via the Visual Studio Code editor, install addon via HACS etc, but don’t understand what quirks, etc are.

Thanks in advance for any help provided!!

Please also post the device signature, as I asked above.

Hey koyingChris Browet

Here it is:

{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_b6wax7g0",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}

Yeah, same one, so will be included in a future HA release.

Thanks koyingChris Browet

How do I naviage to the the file:

zhaquirks/tuya/valve.py

to manual add the line:

("_TZE200_b6wax7g0", "TS0601"),

to my HA OS?

PS I have HA OS installed on a ESXI server, not a Raspberry Pi

Thanks in advance for any help!!

  1. Create a custom quirk directory in HA, e.g., /config/custom_zha_quirks
  2. In configuration.yaml, point to this directory:
zha:
  custom_quirks_path: /config/custom_zha_quirks/
  1. in this directory, create a file valve.py with https://raw.githubusercontent.com/zigpy/zha-device-handlers/dev/zhaquirks/tuya/valve.py as content
1 Like

Hi Chris

I followed your instruction and got the custom ZHA quirk setup and now my TRV is exposing entities in HA, so thank you.

However, I have a few issues maybe you can help me with:

  1. The set temperature is out by a factor of 10. When I set the temp on the TRV to say 20 degrees, it’s shown as 2 degrees in HA.:

image

Furthermore, when I set the TRV to 20 degrees and the room temp is 24 degrees (as shown in the pic above), the TRV is off (or idle) but in HA it is showing as heating.

  1. The battery status is not shown at all in HS for the TRV:

image

  1. Finally, I think the issue might be becuase the TRV in > Developer Tools > States, I can see the TRV only has 1 supported feature, whereas my other TRV (which is very similar) shows 17 supported features:

The new added TRV with custom ZHA quirks:

My existing very similar TRV which was discovered automatically by ZHA:

Hope the above helps when adding this TRV to the next release / future release of HA / ZHA

Can’t help you with the functionalities, I don’t own that device.
Just keep in mind that those tuya devices are produced by people that barely know what they are doing, zigbee-wise.

Tuya, the company, is just a generic integrator that provide “blueprints” firmwares to random chinese producers to include in their “connected” products. Expect anything :wink:

1 Like

Kal,

I’m a total Zigbee beginner but I think I got this sorted by playing around. Head in to the ‘Manage clusters’ option in the integrations screen and try tweaking the ‘temperature calibration’ under the ‘moesmanufcluster’. I think this is a scaling factor? So you could try 1,10 or 0.1.

Health warning: I am not an expert!

T