So, I have, about since they became available, two Aqara Motion Sensors (really budget-friendly at around €140 for both, if I remember correctly), but I don’t really like them, the feel, the handling — and honestly, in my opinion they’re prohibitively expensive for what they offer.
So when I was recently browsing TEMU and came across a deal for an RSH ZigBee 3.0 mmWave Radar sensor, including shipping, for acceptable €16.30, that triggered my intrest.
Well, for €16 — and considering TEMU’s refund policy — you can’t really go wrong.
So I went for it. Fast forward three weeks (after the thing literally took the scenic route on the Southern version of the Trans-Sib Railway through Kazakhstan), and it finally arrived.
I unboxed it, liked the look of it, liked the handling even more, powered it up, and connected it to ZHA.
It was stupidly easy.
ZHA detected the device—but only showed an LQI value and nothing else…
Dang.
So, I turned to Google and found this:
That pointed me in the right direction, and with help from this guide:
I implemented it. But the code from that thread didn’t work with my TS0601.
Again, from the first link above, I found this issue:
https://github.com/zigpy/zha-device-handlers/issues/4070
And what can I say? The code from opa-gamert just works.
All credit to him — my only contribution was finding it.
Here’s the Python code you need to zuGutenberg (paste, for the non-Germans
) into your quirk file:
import logging
from typing import Final
from zigpy.quirks.v2 import QuirkBuilder, BinarySensorDeviceClass
import zigpy.types as t
from zigpy.zcl.foundation import ZCLAttributeDef
from zhaquirks.tuya import (
TuyaLocalCluster,
TuyaPowerConfigurationCluster2AAA,
)
from zhaquirks.tuya.mcu import TuyaMCUCluster, DPToAttributeMapping
from zigpy.quirks.v2.homeassistant import EntityPlatform, EntityType
_LOGGER = logging.getLogger(__name__)
class PresenceState(t.enum8):
none = 0x00
presence = 0x01
peaceful = 0x02
small_movement = 0x03
large_movement = 0x04
class HumanPresenceSensorManufCluster(TuyaMCUCluster):
"""Custom Tuya cluster for _TZE204_no6qtgtl human presence sensor."""
cluster_id = 0xEF00
class AttributeDefs(TuyaMCUCluster.AttributeDefs):
presence_state: Final = ZCLAttributeDef(
id=0x0001, type=t.uint8_t, access="rp", is_manufacturer_specific=True
)
near_detection: Final = ZCLAttributeDef(
id=0x0003, type=t.uint16_t, access="rp", is_manufacturer_specific=True
)
far_detection: Final = ZCLAttributeDef(
id=0x0004, type=t.uint16_t, access="rp", is_manufacturer_specific=True
)
target_distance: Final = ZCLAttributeDef(
id=0x0009, type=t.uint16_t, access="rp", is_manufacturer_specific=True
)
static_sensitivity: Final = ZCLAttributeDef(
id=0x0065, type=t.uint8_t, access="rp", is_manufacturer_specific=True
)
motion_sensitivity: Final = ZCLAttributeDef(
id=0x0066, type=t.uint8_t, access="rp", is_manufacturer_specific=True
)
# lighting_mode verwijderd
dp_to_attribute: dict[int, DPToAttributeMapping] = {
1: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "presence_state", converter=PresenceState),
3: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "near_detection"),
4: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "far_detection"),
9: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "target_distance"),
101: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "static_sensitivity"),
102: DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "motion_sensitivity"),
# 103 verwijderd
}
data_point_handlers = {
1: "_dp_2_attr_update",
3: "_dp_2_attr_update",
4: "_dp_2_attr_update",
9: "_dp_2_attr_update",
101: "_dp_2_attr_update",
102: "_dp_2_attr_update",
# 103 verwijderd
}
# Build the quirk
(
QuirkBuilder("_TZE204_no6qtgtl", "TS0601")
.skip_configuration()
.replaces(TuyaPowerConfigurationCluster2AAA)
.adds(HumanPresenceSensorManufCluster, endpoint_id=1)
.binary_sensor(
"presence_state",
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
device_class=BinarySensorDeviceClass.OCCUPANCY,
fallback_name="Presence",
translation_key="occupancy",
)
.enum(
HumanPresenceSensorManufCluster.AttributeDefs.presence_state.name,
PresenceState,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
entity_platform=EntityPlatform.SENSOR,
entity_type=EntityType.STANDARD,
fallback_name="Presence State",
translation_key="presence_state",
)
.number(
HumanPresenceSensorManufCluster.AttributeDefs.target_distance.name,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
step=1,
min_value=0,
max_value=1000,
fallback_name="Target Distance (cm)",
translation_key="target_distance_cm",
)
.number(
HumanPresenceSensorManufCluster.AttributeDefs.near_detection.name,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
step=1,
min_value=0,
max_value=1000,
fallback_name="Near Detection (cm)",
translation_key="near_detection_cm",
)
.number(
HumanPresenceSensorManufCluster.AttributeDefs.far_detection.name,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
step=1,
min_value=0,
max_value=1000,
fallback_name="Far Detection (cm)",
translation_key="far_detection_cm",
)
.number(
HumanPresenceSensorManufCluster.AttributeDefs.motion_sensitivity.name,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
step=1,
min_value=0,
max_value=10,
fallback_name="Motion Sensitivity",
translation_key="motion_sensitivity",
)
.number(
HumanPresenceSensorManufCluster.AttributeDefs.static_sensitivity.name,
HumanPresenceSensorManufCluster.cluster_id,
endpoint_id=1,
step=1,
min_value=0,
max_value=10,
fallback_name="Static Sensitivity",
translation_key="static_sensitivity",
)
# .switch voor lighting_mode verwijderd
.add_to_registry()
)
Unfortunatly, I cant offer you a Link to the product, TEMU says its sold out… I would have loved to buy some more…
If I happen to find them again, Ill put the link in here.
Cheerse
Manne