Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tuya mmWave radar 5.8GHz, ZY_HPS01 _TZE204_ex3rcdha #3887

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/test_tuya_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
ZCL_TUYA_MOTION_V4 = b"\tL\x01\x00\x05\x69\x01\x00\x01\x01" # DP 105
ZCL_TUYA_MOTION_V5 = b"\tL\x01\x00\x05\x01\x01\x00\x01\x04" # DP 1, motion is 0x04
ZCL_TUYA_MOTION_V6 = b"\tL\x01\x00\x05\x01\x04\x00\x01\x02" # DP 1, enum
ZCL_TUYA_MOTION_v7 = b"\tL\x01\x00\x05\x01\x01\x00\x01\x00" # DP 1, Inv
ZCL_TUYA_MOTION_V7 = b"\tL\x01\x00\x05\x01\x01\x00\x01\x00" # DP 1, Inv
ZCL_TUYA_MOTION_V8 = b"\tL\x01\x00\x05\x65\x01\x00\x01\x00" # DP 101, Inv


zhaquirks.setup()
Expand Down Expand Up @@ -53,10 +54,10 @@
("_TZE204_kyhbrfyl", "TS0601", ZCL_TUYA_MOTION),
("_TZ6210_duv6fhwt", "TS0601", ZCL_TUYA_MOTION),
("_TZE204_1youk3hj", "TS0601", ZCL_TUYA_MOTION),
("_TZE200_3towulqd", "TS0601", ZCL_TUYA_MOTION_v7),
("_TZE200_1ibpyhdc", "TS0601", ZCL_TUYA_MOTION_v7),
("_TZE200_bh3n6gk8", "TS0601", ZCL_TUYA_MOTION_v7),
("_TZE200_ttcovulf", "TS0601", ZCL_TUYA_MOTION_v7),
("_TZE200_3towulqd", "TS0601", ZCL_TUYA_MOTION_V7),
("_TZE200_1ibpyhdc", "TS0601", ZCL_TUYA_MOTION_V7),
("_TZE200_bh3n6gk8", "TS0601", ZCL_TUYA_MOTION_V7),
("_TZE200_ttcovulf", "TS0601", ZCL_TUYA_MOTION_V7),
("_TZE204_sxm7l9xa", "TS0601", ZCL_TUYA_MOTION_V4),
("_TZE204_e5m9c5hl", "TS0601", ZCL_TUYA_MOTION_V4),
("_TZE204_dapwryy7", "TS0601", ZCL_TUYA_MOTION_V6),
Expand All @@ -65,6 +66,7 @@
("_TZE200_2aaelwxk", "TS0225", ZCL_TUYA_MOTION),
("_TZE200_2aaelwxk", "TS0601", ZCL_TUYA_MOTION),
("_TZE200_kb5noeto", "TS0601", ZCL_TUYA_MOTION),
("_TZE204_ex3rcdha", "TS0601", ZCL_TUYA_MOTION_V8),
],
)
async def test_tuya_motion_quirk_occ(zigpy_device_from_v2_quirk, model, manuf, occ_msg):
Expand Down
94 changes: 94 additions & 0 deletions zhaquirks/tuya/tuya_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,3 +1516,97 @@ class TuyaMotionDetectionMode(t.enum8):
.skip_configuration()
.add_to_registry()
)


# Tuya mmWave radar 5.8GHz, ZY_HPS01
(
TuyaQuirkBuilder("_TZE204_ex3rcdha", "TS0601")
.tuya_illuminance(dp_id=12)
.tuya_dp(
dp_id=101,
ep_attribute=TuyaOccupancySensing.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=lambda x: x == 0,
)
.adds(TuyaOccupancySensing)
.tuya_number(
dp_id=104,
attribute_name="presence_timeout",
type=t.uint16_t,
device_class=SensorDeviceClass.DURATION,
unit=UnitOfTime.SECONDS,
min_value=1,
max_value=180,
step=1,
translation_key="fading_time",
fallback_name="Fading time",
)
.tuya_number(
dp_id=105,
attribute_name="move_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="move_sensitivity",
fallback_name="Motion sensitivity",
)
.tuya_number(
dp_id=107,
attribute_name="breath_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="breath_sensitivity",
fallback_name="Breath sensitivity",
)
.tuya_number(
dp_id=109,
attribute_name="detection_distance_max",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.CENTIMETERS,
min_value=0,
max_value=600,
step=1,
translation_key="detection_distance_max",
fallback_name="Maximum range",
)
.tuya_number(
dp_id=110,
attribute_name="detection_distance_min",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.CENTIMETERS,
min_value=0,
max_value=600,
step=1,
translation_key="detection_distance_min",
fallback_name="Minimum range",
)
.tuya_number(
dp_id=111,
attribute_name="breath_detection_min",
type=t.uint16_t,
min_value=0,
max_value=600,
step=10,
unit=UnitOfLength.CENTIMETERS,
translation_key="breath_detection_min",
fallback_name="Breath detection min",
)
.tuya_number(
dp_id=112,
attribute_name="breath_detection_max",
type=t.uint16_t,
min_value=0,
max_value=600,
step=10,
unit=UnitOfLength.CENTIMETERS,
translation_key="breath_detection_max",
fallback_name="Breath detection max",
)
Comment on lines +1588 to +1609
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, these don't have the "distance" device class, but still centimeters as the unit. Is that correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be missing for others as well. We should add all of these in another PR.

.skip_configuration()
.add_to_registry()
)
Loading