ZHA how to install custom quirk?

I tried installing the newest quirk for Danfoss ally from https://github.com/zigpy/zha-device-handlers/blob/23a166902e50d5c32019e0d4d32a968715041bb6/zhaquirks/danfoss/thermostat.py by putting it in a directory called quirks under my config dir. This quirk has the following manufacturer attributes:

       0x4000: ("etrv_open_windows_detection", t.enum8),
        0x4003: ("external_open_windows_detected", t.Bool),
        0x4010: ("exercise_day_of_week", t.enum8),
        0x4011: ("exercise_trigger_time", t.uint16_t),
        0x4012: ("mounting_mode_active", t.Bool),
        0x4013: ("mounting_mode_control", t.Bool),
        0x4014: ("orientation", t.Bool),
        0x4015: ("external_measured_room_sensor", t.int16s),
        0x4016: ("radiator_covered", t.Bool),
        0x4020: ("control_algorithm_scale_factor", t.uint8_t),
        0x4030: ("heat_available", t.Bool),
        0x4031: ("heat_supply_request", t.Bool),
        0x4032: ("load_balancing_enable", t.Bool),
        0x4040: ("load_radiator_room_mean", t.uint16_t),
        0x404A: ("load_estimate_radiator", t.uint16_t),
        0x404B: ("regulation_setPoint_offset", t.int8s),
        0x404C: ("adaptation_run_control", t.enum8),
        0x404D: ("adaptation_run_status", t.bitmap8),
        0x404E: ("adaptation_run_settings", t.bitmap8),
        0x404F: ("preheat_status", t.Bool),
        0x4050: ("preheat_time", t.uint32_t),
        0x4051: ("window_open_feature_on_off", t.Bool),
        0xFFFD: ("cluster_revision", t.uint16_t),

However they do not appear in home assistant after installing the quirk. Am I missing something or should all parameters from a quirk be visible in home assistant?

1 Like

I have this in my configuration:

zha:
  enable_quirks: true
  custom_quirks_path: /config/zha_quirks

After that check the device details/Zigbee device signature for the “class” which should reveal your quirk is used if all is ok.

Ok so I have the quirk in a dir called /config/quirks/danfoss and added

zha:
  enable_quirks: true
  custom_quirks_path: /config/quirks

to my config. I can also see that the /config/quirks/danfoss dir get a __pycache__ dir on restart which I assume means that it is read.
However my thermostats do not gain any new attributes after a reboot? I would expect them to get e.g ‘load_estimate_radiator’ based on the quirk but maybe something needs to be modified elsewhere also?


I think it’s still using the original quirk.

Personnally I had made a quirk for a LIDL light and started from the original quirk.
I renamed the main class to make a distinction in the name and appended ‘Local’:

class RGBCCTLightLocal(CustomDevice):

I called the file ‘rgbcct.py’ and it shows up like ‘rgbcct.RGBCCTLIghtLocal’:

So clearly, your quirk is not applied to the device.

What is important is that the signature corresponds to the definition returned by the firmware. In the “replacement” you’re free to define the apparent definition.

The logs can be a good place to check for errors, you could also add a LOGGER to your quirk and log a message when it enters some of the code.

You may have a basic syntax error - you could run tools such as flake8, blake, mypy to help you identify common mistakes before restarting (pip install flake8 flake8-2020 flake8-bugbear flake8-comprehensions blake mypy and run blake, flake8, mypy on your quirk).

So if I understand it correctly if I’m seeing this
image
ZHA is using quirk already without me doing anything?
image
I saw some variants of the quirk on the github I wanted to try, but there is nothing like quirks in the /config so what is the path ZHA is using to load quirks?

I’m using home assistant supervised on arm64 and zigbee2mqtt in addons says it is unsupported and honestly I tried mqtt years ago and would like to stay away from it.

I have tried to the custom_quirks_path like this, but it just says error in log

Update:
Oh ok i can click on the line in the log view and it gives back detail like

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!

@evlo
I get the same Type Error message as you got when trying to use this custom quirk for my Popp Thermostats: add D5X84YU to Danfoss quirk by hertleinj ¡ Pull Request #1148 ¡ zigpy/zha-device-handlers ¡ GitHub

How did you fix it?

I didn’t find a fix, I have changed to zigbee2mqtt for my zigbee stuff.

It still does not play nice with tuya battery switches. But where possible I’m moving to mains esphome based devices and when i need battery operated I go for BT + BT proxy.