Getting ZHA custom quirks to work with Tuya TS0601 in-ceiling motion sensor

Hi there,

Currently I am trying to get custom quirks working for a Tuya motion sensor (mmWave and illuminance.
The exact device model is: TS0601 - _TZE204_ztc6ggyl.
But I cannot get the device to work with a custom quirk.
By default it takes this quirk: “zhaquirks.tuya.ts0601_motion.MmwRadarMotion”
Which is fine, as in it works, but there is no way to change its settings easily, other than trying to figure what to do when you click on “Manage Zigbee Device” from the device settings in HA.

I’ve found a quirk on github where you should in theory be able to change the device’s settings as screenshots state that you should have some sliders. The script/quirk can be found here: Add support for ZY-M100 wall mount by blakadder · Pull Request #1928 · zigpy/zha-device-handlers · GitHub

From what I’ve understood with these custom quirks, is that you need to do the following:

  1. Remove the device you want to use the custom quirk
  2. Create custom quirk folder: “custom_zha_quirks”
  3. Enable custom quirks from configuration like so:
zha:
  enable_quirks: true
  custom_quirks_path: /config/custom_zha_quirks
  1. Restart HA
  2. Put device in pairing mode (in this case hold the reset button for more than 6 seconds)
  3. Go to the zigbee dongle (Sonoff Zigbee 3.0 USB Dongle Plus V2 in my case), click configure > Add Device
  4. Device is found, give it a name and that’s it.

When I go to the just paired device, it is still using the old/default quirk part of ZHA: “zhaquirks.tuya.ts0601_motion.MmwRadarMotion”. I would now expect to see: “ts0601_motion.TuyaMmwRadarOccupancy” as that is the name of the python file inside the custom quirks folder that I created.

Before actually pairing the device I did enable debug logging from the ‘Integrations’ tab on the zigbee dongle device. But I couldn’t find anything related to this custom quirk i’ve added.

I am using HA 2022.12.8, supervisor 2022.12.1 and HASS version 9.4.

I start to question now, is there even a way to setup a qustom quirk when the device is already supported from ZHA?

Hope to find some answers here, thanks! :slight_smile:

3 Likes

Having the same issue, yet to find a work around

Stuck with same quirk

I simply have this in my configuration.yaml file:-

zha:
  custom_quirks_path: /config/custom_zha_quirks/

I have had this happen before with Tuya smart plugs and in the end I had to edit the quirk to make it work. It might be worth learning how to do this if you use local quirks alot, as I’ve found particularly with ZHA that I need a few of these.

To start, getting the diagnostics of your device and comparing the clusters and attributes in the quirk might point you in the right direction.

Go to the device and click the download diagnostics from menu to the left of the reconfigure button:-

Once you have the file downloaded the device will be at the bottom, in my case it looks like this:-

"user_given_name": "Ajax Plug - First Floor Hall",
    "device_reg_id": "2ff51f2921bf1c7e283ad2ec5edc370e",
    "area_id": null,
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "ON_OFF_PLUG_IN_UNIT",
          "id": 266
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0000": {
                "attribute_name": "zcl_version",
                "value": 3
              },
              "0x0001": {
                "attribute_name": "app_version",
                "value": 69
              },
              "0x0003": {
                "attribute_name": "hw_version",
                "value": 1
              },
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "_TZ3000_1h2x4akh"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "TS011F"
              },
              "0x0007": {
                "attribute_name": "power_source",
                "value": 1
              },
              "0xfffe": {
                "attribute_name": "attr_reporting_status",
                "value": 0
              }
            },
            "unsupported_attributes": {
              "0x4000": {
                "attribute_name": "sw_build_id"
              },
              "0x0009": {
                "attribute_name": "generic_device_type"
              },
              "0x000e": {
                "attribute_name": "product_label"
              },
              "0x000a": {
                "attribute_name": "product_code"
              },
              "0x000c": {
                "attribute_name": "manufacturer_version_details"
              },
              "0x000d": {
                "attribute_name": "serial_number"
              }
            }
          },
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0006": {
            "endpoint_attribute": "on_off",
            "attributes": {
              "0x0000": {
                "attribute_name": "on_off",
                "value": 0
              },
              "0x4001": {
                "attribute_name": "on_time",
                "value": 0
              },
              "0x4002": {
                "attribute_name": "off_wait_time",
                "value": 0
              },
              "0x8000": {
                "attribute_name": "child_lock",
                "value": 0
              },
              "0x8001": {
                "attribute_name": "backlight_mode",
                "value": 1
              },
              "0x8002": {
                "attribute_name": "power_on_state",
                "value": 2
              }
            },
            "unsupported_attributes": {
              "0x4003": {
                "attribute_name": "start_up_on_off"
              }
            }
          },
          "0x0702": {
            "endpoint_attribute": "smartenergy_metering",
            "attributes": {
              "0x0000": {
                "attribute_name": "current_summ_delivered",
                "value": 1691
              },
              "0x0200": {
                "attribute_name": "status",
                "value": 0
              },
              "0x0300": {
                "attribute_name": "unit_of_measure",
                "value": 0
              },
              "0x0301": {
                "attribute_name": "multiplier",
                "value": 1
              },
              "0x0302": {
                "attribute_name": "divisor",
                "value": 100
              },
              "0x0303": {
                "attribute_name": "summation_formatting",
                "value": 0
              },
              "0x0306": {
                "attribute_name": "metering_device_type",
                "value": 0
              }
            },
            "unsupported_attributes": {
              "0x0400": {
                "attribute_name": "instantaneous_demand"
              },
              "0x0304": {
                "attribute_name": "demand_formatting"
              }
            }
          },
          "0x0b04": {
            "endpoint_attribute": "electrical_measurement",
            "attributes": {
              "0x0505": {
                "attribute_name": "rms_voltage",
                "value": 237
              },
              "0x0508": {
                "attribute_name": "rms_current",
                "value": 0
              },
              "0x050b": {
                "attribute_name": "active_power",
                "value": 0
              },
              "0x0602": {
                "attribute_name": "ac_current_multiplier",
                "value": 1
              },
              "0x0603": {
                "attribute_name": "ac_current_divisor",
                "value": 1000
              }
            },
            "unsupported_attributes": {
              "0x0300": {
                "attribute_name": "ac_frequency"
              },
              "0x0601": {
                "attribute_name": "ac_voltage_divisor"
              },
              "0x0302": {
                "attribute_name": "ac_frequency_max"
              },
              "0x0600": {
                "attribute_name": "ac_voltage_multiplier"
              },
              "0x0604": {
                "attribute_name": "ac_power_multiplier"
              },
              "0x0605": {
                "attribute_name": "ac_power_divisor"
              },
              "0x0401": {
                "attribute_name": "ac_frequency_divisor"
              },
              "0x0507": {
                "attribute_name": "rms_voltage_max"
              },
              "0x0400": {
                "attribute_name": "ac_frequency_multiplier"
              },
              "0x0000": {
                "attribute_name": "measurement_type"
              },
              "0x050a": {
                "attribute_name": "rms_current_max"
              },
              "0x0403": {
                "attribute_name": "power_divisor"
              },
              "0x0803": {
                "attribute_name": "ac_active_power_overload"
              },
              "0x050d": {
                "attribute_name": "active_power_max"
              },
              "0x050f": {
                "attribute_name": "apparent_power"
              },
              "0x0402": {
                "attribute_name": "power_multiplier"
              },
              "0x0801": {
                "attribute_name": "ac_voltage_overload"
              }
            }
          },
          "0xe000": {
            "endpoint_attribute": "tuya_is_pita_0",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xe001": {
            "endpoint_attribute": "tuya_external_switch_type",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x000a": {
            "endpoint_attribute": "time",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}

Could it be that you didnt copy the full contents of the diagnostics of the device? as there is no actual “bottom” of the file. Currently its invalid json :slight_smile:
Or maybe we miss half of the message?

Hi,

Has anyone got this custom quirk working? I bought a batch of these to run on ZHA and they’re super sensitive (detecting movement behind walls).

Even some guidance to amend settings via the ‘manage ZigBee device’ attribute options would be wonderful.
I’m having to add spacers to the rear of sensor to limit interference. :frowning:

edit…

Digging deeper, think I have solved it to get adjustable setting while using an “_TZE204_ztc6ggyl”

I was just pasting an example and left off the closing braces. The example was for a smart plug, yours will be different.

How did you solve it? I’d love the solution.

Follow this GitHub post, take your time, fairly easy.

Post and quirk by Aquemy

1 Like

@TeaMan Thanks for the message.
In fact i already had that github issue bookmarked.
But tried it again and now i got it working!
One thing that i did change is to add a forward / after the custom_zha_quirks path.
Maybe that was the reason why it didnt work?
Anyway, i can continue integrating these devices properly now :slight_smile:

In fact, ZHA is apparently smart enought to apply the custom quirk to all sensors already.
So i think only reboot of HA was needed before custom quirk was picked up! That will save some work :slight_smile:

Glade you’ve got your sensor(s) working better!

That happened to me, removed one sensor from HA, rebooted and suddenly all other sensors were populated with the number adjustments…simples!

See if you get Cluster attribute errors in your HA Core log after changes, I had loads this morning but things appear to be working fine.

I have added the error log to this GitHub page, hoping for a resolve of some kind. :slight_smile:

edit: apparently an illuminance bug in the quirk, a possible fix is in the post.

@TeaMan I didnt see the error in the logs. I guess it shouldnt hurt to update that line anyway?

Has your device got the illuminance sensor? if so, errors may randomly appear later.

I’m about to make the changes. But yes, won’t do any harm you doing them. Maybe wait until you see the errors. :slight_smile:

Make Changes to line 240

@TeaMan Yes it has one. Looks to work fine, until now that is…
I’ll save the changes and they will be picked up on next restart :slight_smile:

Cool, I’ve restarted and things appear fine including illuminance changes.
We’ll see if more errors pop up tomorrow.

update: No more errors logged, change made looks good!

1 Like

Is anyone having problems with this following the recent HA update?

@HugosDad I didnt have any problems with the zha config itself.
I did have problems with all devices being unavailable and not working at all because of errors in the quirk.
That was caused by an update in ZHA that broke some Tuya related stuff (afaik). I just took over the changes from this ticket/thread here: https://github.com/zigpy/zha-device-handlers/pull/1928 and that got it working for me again :slight_smile:

1 Like

I have the devices working, but without the configuration options available.

Is the long term intention for the quirk (that enables the config options) to be consolidated within the standard ZHA code?

I read through a couple of Github threads relating to these devices and am still no clearer if they are officially supporting them in ZHA or not?

For me, I only have one device that will show the configuration options when I enable to custom quirks, which I am reluctant to leave enabled all the time, since it doesn’t work for my other 5 devices.

What’s needed to bring the configuration options to mainstream HA?

That is all cool and all but this quirk is missing lux detection and I can tell that ZHA can read this parameter as seen below:

Does anyone know how to add this to quirk so it can show up as entity in HA?