jacekk015 / zha_quirks

All quirks in one place
MIT License
144 stars 20 forks source link

Quirks stopped working #35

Closed fingolfin closed 8 months ago

fingolfin commented 1 year ago

I have a _TZE200_6rdj8dzm and this quirk used to work just fine for me. But it stopped after a Home Assistant update or config change some time ago (not sure when exactly, as it was summer and so it was unused). Looking at the logs, I see a Python stack trace:

2023-11-02 07:20:33.946 ERROR (MainThread) [zhaquirks] Unexpected exception importing custom quirk 'ts0601_trv_me167'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zhaquirks/__init__.py", line 460, in setup
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/quirks/ts0601_trv_me167.py", line 151, in <module>
    class ME167ManufCluster(TuyaManufClusterAttributes):
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 167, in __init_subclass__
    raise TypeError(f"Duplicate definitions exist for {duplicates}")
TypeError: Duplicate definitions exist for ['target_temperature']
2023-11-02 07:20:33.963 WARNING (MainThread) [zhaquirks] Loaded custom quirks. Please contribute them to https://github.com/zigpy/zha-device-handlers
2023-11-02 07:20:48.575 ERROR (MainThread) [homeassistant.components.denonavr.media_player] Error Power attribute of zone Main not found on update occurred in method async_update for De
non AVR receiver
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/denonavr/media_player.py", line 181, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/denonavr/media_player.py", line 323, in async_update
    await receiver.async_update()
  File "/usr/local/lib/python3.11/site-packages/denonavr/denonavr.py", line 180, in async_update
    await self._device.async_update(global_update=True, cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 178, in async_update
    await self.async_update_power(global_update=global_update, cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 431, in async_update_power
    await self.async_update_power_status_xml(cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 494, in async_update_power_status_xml
    raise AvrProcessingError(
denonavr.exceptions.AvrProcessingError: Power attribute of zone Main not found on update
2023-11-02 07:20:52.758 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform fritz is taking over 10 seconds.
2023-11-02 07:20:53.643 ERROR (MainThread) [homeassistant.components.homekit.type_thermostats] climate.heizung_blaues_bad_thermostat: Received invalid HVAC mode: unavailable
2023-11-02 07:20:58.690 ERROR (MainThread) [homeassistant.components.denonavr.media_player] Error Power attribute of zone Main not found on update occurred in method async_update for De
non AVR receiver
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/denonavr/media_player.py", line 181, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/denonavr/media_player.py", line 323, in async_update
    await receiver.async_update()
  File "/usr/local/lib/python3.11/site-packages/denonavr/denonavr.py", line 180, in async_update
    await self._device.async_update(global_update=True, cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 178, in async_update
    await self.async_update_power(global_update=global_update, cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 431, in async_update_power
    await self.async_update_power_status_xml(cache_id=cache_id)
  File "/usr/local/lib/python3.11/site-packages/denonavr/foundation.py", line 494, in async_update_power_status_xml
    raise AvrProcessingError(

and so on.

So it seems there is a conflict with the denonavr integration? But how is that even possible, I would have expected these things to be isolated from each other due to namespacing?

fingolfin commented 1 year ago

Sorry, I should have included more information about my setup:

Please let me know if I can provide any other information that might be helpful.

Also, I just want to stress that I realize that I am not at all entitled to any help from you, you already did a lot by providing these quirks. But just in case you have any ideas what might resolve this, I'd really appreciate it.

(In the end I guess I could de-install the denonavr integration and hope this will fix it, but (a) I'd really like to use it, and (b) perhaps getting to the bottom of this will help other users?)

jacekk015 commented 1 year ago

Are you sure you're using latest quirk version?? You could just re-download and replace file.

Error says that there's a duplicate:

TypeError: Duplicate definitions exist for ['target_temperature']

If you Ctrl+F on the code window and search for "target_temperature" you will see that there's no duplicate of "target_temperature" https://github.com/jacekk015/zha_quirks/blob/main/ts0601_trv_me167.py

fingolfin commented 1 year ago

Yes I am sure it is the latest quirk version. In fact I have a git clone of this repository inside config/quirks/, and that's the only quirks directory. And the error messages clearly have the path to that file in them.

And yes, the first thing I did before reporting this was to check that target_temperature only occurs once in your code, but the complaint doesn't seem to be that your code has target_temperature twice, but rather that something else already defines target_temperature. The error is instead raised by code in zigpy in zigpy/zcl/__init__.py. This seems to be a relatively recent check (it was "only" added in May 2023 to zigpy), which may explain why it worked for me before?

Last night I experimemented some more and tried what happens if I deactivate the denonavr integration. I did so and restarted, and now the log is somewhat different:

2023-11-20 23:22:47.844 ERROR (MainThread) [zhaquirks] Unexpected exception importing custom quirk 'ts0601_trv_me167'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zhaquirks/__init__.py", line 460, in setup
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/quirks/ts0601_trv_me167.py", line 151, in <module>
    class ME167ManufCluster(TuyaManufClusterAttributes):
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 167, in __init_subclass__
    raise TypeError(f"Duplicate definitions exist for {duplicates}")
TypeError: Duplicate definitions exist for ['target_temperature']
2023-11-20 23:22:47.852 WARNING (MainThread) [zhaquirks] Loaded custom quirks. Please contribute them to https://github.com/zigpy/zha-device-handlers
2023-11-20 23:22:58.038 WARNING (MainThread) [zigpy.zcl] [0x3E5B:1:0xef00] Unknown cluster command 2 b'\x00l\x05\x02\x00\x04\x00\x00\x00\xc8'
2023-11-20 23:22:58.048 WARNING (MainThread) [zigpy.zcl] [0x3E5B:1:0xef00] Unknown cluster command 2 b'\x00m\x05\x02\x00\x04\x00\x00\x00\xc8'
2023-11-20 23:22:58.063 WARNING (MainThread) [zigpy.zcl] [0x3E5B:1:0xef00] Unknown cluster command 2 b'\x00m\x05\x02\x00\x04\x00\x00\x00\xc8'
2023-11-20 23:22:58.245 WARNING (MainThread) [zigpy.zcl] [0x3E5B:1:0xef00] Unknown cluster command 2 b'\x00|\x05\x02\x00\x04\x00\x00\x00\xbe'
... [many more similar messages; note that I don't know whether they are related to zha_quirk]
jacekk015 commented 1 year ago

Nope. ZCL init loads the quirk and it sees duplicate of "target_temperature" - error is moving up like a bubble. Quirk code can't brake just by laying on the disk drive. If you can't just download the quirk and put it there then I can't help you.

Duplicate.... was an error of very, very old quirks. They've started to show since they made an update in ZHA/ZCL.

"target_temperature" is just a name in the quirk - it's on the Manufacturer specific attributes side. You could also call it "my_beautiful_temperature" - it totally doesn't matter. It's just a name to show on the Attributes list in Manage cluster devices. Attribute ID's is what's matter and the temp attribute is:

ME167_TEMPERATURE_ATTR = 0x0205

That attribute is then mapped to "local_temperature" attribute and that's what the HA sees for TRV room temp.