#ZHA Custom Quirk for Tuya Soil Sensor not being applied

7 messages · Page 1 of 1 (latest)

hollow carbon
#

I bought a Tuya soil sensor from AliExpress and it came as a model "_TZE284_myd45weu" which isn't supported by ZHA yet. It is supported by Z2M though (https://github.com/Koenkk/zigbee-herdsman-converters/commit/eb426d4ce862c392e3b45ac27a6e95cc042ad72a). So according to that file, the same quirk that handles _TZE200_myd45weu will also handle _TZE284_myd45weu. I found a zha quirk here (https://github.com/zigpy/zha-device-handlers/blob/04ac526e91be12a8d994363da4da4003760aa205/zhaquirks/tuya/ts0601_sensor.py) and it handles _TZE200_myd45weu so I tried modifying it to also handle my _TZE284_myd45weu:

        MODELS_INFO: [
            ("_TZE200_myd45weu", "TS0601"),
            ("_TZE200_ga1maeof", "TS0601"),
            ("_TZE284_myd45weu", "TS0601"),
        ],

I saved the file in /config/quirks/ts0601_sensor.py (see image) and added this to my /homeassistant/configuration.yaml file:

zha:
  enable_quirks: true
  custom_quirks_path: /config/quirks

I restarted HA and readded the device to ZHA, however, it doesn't appear that the quirk is taking effect (see image). Any idea what I'm doing wrong?

GitHub

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devi...

hot depot
hollow carbon
#

I copied that file and added _TZE284_myd45weu to the list here:

(
    TuyaQuirkBuilder("_TZE200_myd45weu", "TS0601")
    .applies_to("_TZE200_ga1maeof", "TS0601")
    .applies_to("_TZE200_9cqcpkgb", "TS0601")
    .applies_to("_TZE204_myd45weu", "TS0601")
    .applies_to("_TZE200_2se8efxh", "TS0601")  # Immax Neo
    .applies_to("_TZE284_myd45weu", "TS0601")
    .tuya_temperature(dp_id=5)
    .tuya_battery(dp_id=15)
    .tuya_soil_moisture(dp_id=3)
    .skip_configuration()
    .add_to_registry()
)

Reboot HA, readded the device, and still no readings (see image). It also doesn't list the quirk in the Zigbee info so I still think it's not being applied. Any ideas how I can test / fix that?

hollow carbon
#

I'm pretty sure I've got the path and file in the proper spot.

zha:
  enable_quirks: true
  custom_quirks_path: /config/quirks
#

I've tried ./quirks also (which HA confirms is a valid directory) and upon readding the device, it's still not listing any quirk applied.

hollow carbon
#

Looking through the logs, I see it didn't like that file you linked me to:

Unexpected exception importing custom quirk 'tuya_sensor'

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zhaquirks/__init__.py", line 479, in setup
    spec.loader.exec_module(module)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/quirks/tuya_sensor.py", line 252, in <module>
    .add_to_registry(replacement_cluster=NoManufTimeTuyaMCUCluster)
     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TuyaQuirkBuilder.add_to_registry() got an unexpected keyword argument 'replacement_cluster'

with the line in question being: .add_to_registry(replacement_cluster=NoManufTimeTuyaMCUCluster)

#

I deleted the replacement_cluster and another error around tuya_enchantment and now the quirk file is loading with problems. It's being applied to the soil sensor and appears to be working. 🙂