Replies: 5 comments
-
|
+1 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
+1 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I made a custom Quirk for this sensor: """Tuya TS0601 human presence sensor.
This is implemented as a Zigpy quirks v2 `TuyaQuirkBuilder` quirk so the Tuya
MCU datapoints are mapped and configuration settings are exposed as Home
Assistant entities.
Datapoints (from zigbee-herdsman):
- DP 1: presence (trueFalse0)
- DP 4: battery (raw percent)
- DP 9: PIR sensitivity enum (low/middle/high)
- DP 10: PIR delay time enum (15s/30s/60s)
"""
from __future__ import annotations
from enum import Enum
from typing import cast
from zigpy import types as t
from zigpy.profiles import zha
from zigpy.zcl.clusters.measurement import OccupancySensing
from zhaquirks.tuya import TuyaLocalCluster
from zhaquirks.tuya.builder import TuyaQuirkBuilder
def _true_false_0_to_occupancy(value: int) -> int:
"""Convert Tuya "trueFalse0" to ZCL OccupancySensing.occupancy.
zigbee-herdsman "trueFalse0" typically means:
- 0 => True
- 1 => False
OccupancySensing.occupancy is a bitmap; 1 means occupied.
"""
return 1 if int(value) == 0 else 0
class PirSensitivity(t.enum8):
"""PIR sensor sensitivity."""
low = 0
middle = 1
high = 2
class PirTime(t.enum8):
"""PIR delay time in seconds."""
s15 = 0
s30 = 1
s60 = 2
class IhsenoPresenceOccupancy(OccupancySensing, TuyaLocalCluster): # type: ignore[misc]
"""Occupancy cluster backed by Tuya presence datapoints."""
(
TuyaQuirkBuilder()
.applies_to("_TZE284_debczeci", "TS0601")
# The device often reports itself as a SMART_PLUG. Don't override the
# endpoint type; instead add an OccupancySensing cluster backed by Tuya
# datapoints so Home Assistant exposes a presence entity reliably.
.adds(IhsenoPresenceOccupancy)
# DP 1: presence (trueFalse0)
.tuya_dp(
dp_id=1,
ep_attribute=IhsenoPresenceOccupancy.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=_true_false_0_to_occupancy,
)
# DP 4: battery percent (0-100) -> ZCL half-percent (0-200)
.tuya_battery(
dp_id=4,
scale=2,
)
# DP 9/10: PIR configuration (expose as config selects)
.tuya_enum(
dp_id=9,
attribute_name="pir_sensitivity",
enum_class=cast(type[Enum], PirSensitivity),
translation_key="pir_sensitivity",
fallback_name="PIR sensitivity",
)
.tuya_enum(
dp_id=10,
attribute_name="pir_time",
enum_class=cast(type[Enum], PirTime),
translation_key="pir_time",
fallback_name="PIR delay",
)
# The v2 builder will replace the Tuya MCU cluster with a mapping-aware
# subclass and add HA entity metadata.
.add_to_registry(force_add_cluster=True)
) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I'd also like to have this as a native Zigbee device. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the enhancement
I ask to add tuya human presense sensor
Device information
Model: TS0601
Manufacturer: _TZE284_debczeci
"endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x0051", "input_clusters": [ "0x0000", "0x0004", "0x0005", "0xed00", "0xef00" ], "output_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZE284_debczeci", "model": "TS0601", "class": "zigpy.device.Device" }Use cases
Its human presesense sense device working stable and from 2AAA batteries.
Anything else?
The device now working in z2m: Koenkk/zigbee2mqtt#27773
Beta Was this translation helpful? Give feedback.
All reactions