How to setup local ZHA quirks

The binary-sensor called “Accelerometer” was the one I was referring to. Don’t you have attributes under that sensor?

no, it’s binary

When a Zigbee device (and many other integrations) send a message to Home Assistant informing it changed, that is an event. Here you can find more on what events are.

For your automations, you can have a trigger based on a event for this specific device, as described here.

And you can use the trigger’s variables to get information about those values on your event, as described here

You can go to Developer tools > Events and then start listening for zha_event, then move your sensor and you will have an event like this (this is a screens hot from my Aqara sensor’s event):

  • be aware that not all commands will provide the coordinates in the args, so maybe your automation will have to monitor for specific commands on events.

In this case, I probably will get the “X” coordinates under trigger.event.data.args.X or trigger.event.data.args.Y, etc…

Why don’t you share what you are trying to achieve with those values (X, Y and Z) or perhaps share your existing automation developed for DeCONZ so the community can try to help you more?

1 Like

Binary sensors can also have attributes.
Take a look for this binary sensor (and perhaps any other entity within this device) under Developer tools > State and take a look for attributes. Maybe you have this info (X, Y, Z) there.

thankyou so much, this is what I needed!

I already tried this, but did not see the x, y, z values. In any case, I just tried listening to zha_event, and can see the X, Y, Z data. Now I can write an automation based on it thanks to your links above!

1 Like

Hi,

For anyone that’s following this thread. I had to add the database path to in order to actually load the quirks. I added:

zha:
  database_path: /config/zigbee.db 
  enable_quirks: true
  custom_quirks_path: /config/zhaquirks
2 Likes

Update: submitted new how-to guide for adding custom quirks to ZHA to the ZHA Device Handlers repo:

Hi,

I’ve been trying to add a custom quirk for the TuYa Pir Motion and Illuminance sensors I bought, because ZHA recognizes some of the sensors as a smoke alarm and after initializing doesn’t receive any update from the sensor: it just states “clear”.

So I followed the steps as described above and in some other topics (thanks @Hedda for the detailed description):

  1. added to configuration.yaml:
zha: 
  database_path: /config/zigbee.db 
  enable_quirks: true
  custom_quirks_path: /config/zha_quirks/
  1. added a folder “zha_quirks” to “config”
  2. downloaded the .py-file from here and put that in the new folder
  3. deleted the device from ZHA
  4. restarted HA
  5. put the device in discovery mode
  6. added a new device in ZHA

The device was then initialized and added. But it still doesn’t work. If I download diagnostics, it states halfway:

"data": {
    "ieee": "**REDACTED**",
    "nwk": 19146,
    "manufacturer": "_TZE200_3towulqd",
    "model": "TS0601",
    "name": "_TZE200_3towulqd TS0601",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4417,
    "power_source": "Battery or Unknown",
    "lqi": 248,
    "rssi": -38,
    "last_seen": "2023-04-23T21:05:05",
    "available": true,
    "device_type": "EndDevice",

It seems like ZHA doesn’t recognises it should use the installed quirk. The manufacturer and model are the same as described in the quirk:

class PirMotion(CustomDevice):
    """Tuya PIR motion sensor."""

    signature = {
        MODELS_INFO: [("_TZE200_3towulqd", "TS0601")],
        ENDPOINTS: {
            # endpoints=1 profile=260 device_type=0x0402
            # in_clusters=[0x0000, 0x0001, 0x0500],
            # out_clusters=[0x000a, 0x0019]
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    TuyaPowerConfigurationCluster.cluster_id,
                    IasZone.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            }
        },
    }

My question: am I overlooking something here?

I’ll copy the start of the diagnostics file also in, so my installation details are also provided:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.4.6",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.10",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "5.15.84-v8",
    "supervisor": "2023.04.0",
    "host_os": "Home Assistant OS 9.5",
    "docker_version": "20.10.22",
    "chassis": "embedded",
    "run_as_root": true
  },

...some custom components mentioned here...

  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "after_dependencies": [
      "onboarding",
      "usb"
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "config_flow": true,
    "dependencies": [
      "file_upload"
    ],
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "requirements": [
      "bellows==0.35.1",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.97",
      "zigpy-deconz==0.20.0",
      "zigpy==0.54.1",
      "zigpy-xbee==0.17.0",
      "zigpy-zigate==0.10.3",
      "zigpy-znp==0.10.0"
    ],

Suggest post your details to that issue → https://github.com/zigpy/zha-device-handlers/issues/1599

Thanks! I hadn’t seen that thread and found the improved quirk further down the conversation. I updated the quirk on my system and now it works like a charm!

For reference, the working quirk can be found in this post → _TZE200_3towulqd TS0601 Tuya Motion Sensor with illuminance sensor · Issue #1599 · zigpy/zha-device-handlers · GitHub

How do you manage to solve the problem ?
I think also that it used the quirk from the library and not the custom one.
I used the last py file posted in the the issue _TZE200_3towulqd TS0601 Tuya Motion Sensor with illuminance sensor · Issue #1599 · zigpy/zha-device-handlers · GitHub
Thank you for your help

I’m also interested in solving his issue as I am bumping into the same.

Following the instructions did not work. I am not seeing the new quirk name showing under the device, despite re-pairing, restarting, etc.

Post new issue to ZHA Device Handlers for your device signature ID if there is not already one → https://www.home-assistant.io/integrations/zha#how-to-add-support-for-new-and-unsupported-devices

I’m silly. The quirk I was using was not for my device :sweat_smile:

New comment

Can anybody help?

FYI, posted an updated version the the community guide section here → Zigbee Guide: How-to setup local custom device handler quirks in ZHA integration

2 Likes

@cckp database_path was the missing piece for me. Thanks for posting!