Hi, I couldnt find any quirk to get this working so made one myself its tested and working 100%
"""ZHA quirk for the AOYAN AY-303Z Zigbee soil moisture sensor.
The AY-303Z is a white-label of the HOBEIAN ZG-303Z / COOLO CS-201Z. It exposes
standard ZCL clusters, but the useful data lives in Tuya datapoints (DPs) on
the 0xEF00 cluster:
DP 3 soil moisture %
DP 5 temperature 0.1 degC
DP 15 battery %
DP 106 dry-soil alarm bool
DP 109 air humidity %
DP 102 soil moisture calibration -30..30 %
DP 104 temperature calibration -2.0..2.0 degC (x10 on the wire)
DP 105 humidity calibration -30..30 %
DP 110 dry-soil warning threshold 0..100 %
DP 111 temperature sampling interval 5..3600 s
DP 112 soil sampling interval 5..3600 s
Without a quirk, ZHA shows the soil moisture as "Humidity" because the sensor
reports it on the standard RelativeHumidity cluster (0x0405). This quirk
removes that cluster and exposes a real soil moisture entity instead.
Install: copy to /config/zha_quirks/ and set in configuration.yaml:
zha:
custom_quirks_path: /config/zha_quirks/
"""
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import PowerConfiguration
from zigpy.zcl.clusters.measurement import RelativeHumidity
from zhaquirks.builder import (
PERCENTAGE,
BinarySensorDeviceClass,
EntityType,
NumberDeviceClass,
SensorDeviceClass,
SensorStateClass,
UnitOfTemperature,
UnitOfTime,
)
from zhaquirks.tuya import TUYA_CLUSTER_ID
from zhaquirks.tuya.builder import TuyaQuirkBuilder
# If the "Dry soil" entity reads backwards on your unit (ON while the soil is
# wet), change this to False and restart Home Assistant.
DRY_ALARM_INVERTED = True
def _dry_alarm(value: int) -> bool:
"""Convert the raw DP 106 value to True = soil is dry."""
return (not bool(value)) if DRY_ALARM_INVERTED else bool(value)
(
# The manufacturer string really does have two trailing spaces.
TuyaQuirkBuilder("AOYAN ", "AY-303Z")
.applies_to("AOYAN", "AY-303Z")
# Wake up the Tuya side of the device when it joins.
.tuya_enchantment()
# --- Measurements -----------------------------------------------------
.tuya_soil_moisture(dp_id=3)
.tuya_temperature(dp_id=5, scale=10)
# Battery already works over the standard cluster; also accept DP 15.
.tuya_dp(
dp_id=15,
ep_attribute=PowerConfiguration.ep_attribute,
attribute_name=PowerConfiguration.AttributeDefs.battery_percentage_remaining.name,
converter=lambda x: x * 2,
)
# 0x0405 carries soil moisture on this device, not air humidity.
.removes(RelativeHumidity.cluster_id)
.tuya_sensor(
dp_id=109,
attribute_name="air_humidity",
type=t.uint16_t,
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
unit=PERCENTAGE,
translation_key="air_humidity",
fallback_name="Air humidity",
)
.tuya_dp_attribute(
dp_id=106,
attribute_name="dry_soil",
type=t.Bool,
converter=_dry_alarm,
access=foundation.ZCLAttributeAccess.Read
| foundation.ZCLAttributeAccess.Report,
)
.binary_sensor(
attribute_name="dry_soil",
cluster_id=TUYA_CLUSTER_ID,
endpoint_id=1,
entity_type=EntityType.STANDARD,
device_class=BinarySensorDeviceClass.PROBLEM,
translation_key="dry_soil",
fallback_name="Dry soil",
)
# --- Settings ---------------------------------------------------------
.tuya_number(
dp_id=110,
attribute_name="soil_warning_threshold",
type=t.uint32_t,
unit=PERCENTAGE,
min_value=0,
max_value=100,
step=1,
translation_key="soil_warning_threshold",
fallback_name="Dry soil warning threshold",
)
.tuya_number(
dp_id=112,
attribute_name="soil_sampling_interval",
type=t.uint32_t,
unit=UnitOfTime.SECONDS,
min_value=5,
max_value=3600,
step=1,
device_class=NumberDeviceClass.DURATION,
translation_key="soil_sampling_interval",
fallback_name="Soil sampling interval",
)
.tuya_number(
dp_id=111,
attribute_name="temperature_sampling_interval",
type=t.uint32_t,
unit=UnitOfTime.SECONDS,
min_value=5,
max_value=3600,
step=1,
device_class=NumberDeviceClass.DURATION,
translation_key="temperature_sampling_interval",
fallback_name="Temperature sampling interval",
)
.tuya_number(
dp_id=102,
attribute_name="soil_moisture_calibration",
type=t.int32s,
unit=PERCENTAGE,
min_value=-30,
max_value=30,
step=1,
translation_key="soil_moisture_calibration",
fallback_name="Soil moisture calibration",
)
.tuya_number(
dp_id=104,
attribute_name="temperature_calibration",
type=t.int32s,
unit=UnitOfTemperature.CELSIUS,
min_value=-2,
max_value=2,
step=0.1,
multiplier=0.1,
device_class=NumberDeviceClass.TEMPERATURE_DELTA,
translation_key="temperature_calibration",
fallback_name="Temperature calibration",
)
.tuya_number(
dp_id=105,
attribute_name="humidity_calibration",
type=t.int32s,
unit=PERCENTAGE,
min_value=-30,
max_value=30,
step=1,
translation_key="humidity_calibration",
fallback_name="Humidity calibration",
)
.add_to_registry()
)
To use it, save this file into your custom_quirks_path folder, remove the device if already paird reboot and then pair again to ZHA.
Credit: Claude AI