From 382dc33c25638460ea26c81959de34918a6e0e53 Mon Sep 17 00:00:00 2001 From: hwzolin <42085859+hwzolin@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:40:20 +0800 Subject: [PATCH] Add Third Reality plug, motion, water leak sensor (#3426) Co-authored-by: TheJulianJES --- zhaquirks/thirdreality/motion_sensor.py | 40 ++++++++++++++++ zhaquirks/thirdreality/plug.py | 38 +++++++++++++++ zhaquirks/thirdreality/water_leak_sensor.py | 52 +++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 zhaquirks/thirdreality/motion_sensor.py create mode 100644 zhaquirks/thirdreality/plug.py create mode 100644 zhaquirks/thirdreality/water_leak_sensor.py diff --git a/zhaquirks/thirdreality/motion_sensor.py b/zhaquirks/thirdreality/motion_sensor.py new file mode 100644 index 0000000000..b30bb0d5d3 --- /dev/null +++ b/zhaquirks/thirdreality/motion_sensor.py @@ -0,0 +1,40 @@ +"""Third Reality motion sensor devices.""" + +from typing import Final + +from zigpy.quirks import CustomCluster +from zigpy.quirks.v2 import QuirkBuilder +from zigpy.quirks.v2.homeassistant import UnitOfTime +import zigpy.types as t +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef + + +class ThirdRealityMotionCluster(CustomCluster): + """Third Reality's motion sensor private cluster.""" + + cluster_id = 0xFF01 + + class AttributeDefs(BaseAttributeDefs): + """Define the attributes of a private cluster.""" + + detection_interval: Final = ZCLAttributeDef( + id=0x0001, + type=t.uint16_t, + is_manufacturer_specific=True, + ) + + +( + QuirkBuilder("Third Reality, Inc", "3RMS16BZ") + .replaces(ThirdRealityMotionCluster) + .number( + attribute_name=ThirdRealityMotionCluster.AttributeDefs.detection_interval.name, + min_value=5, + max_value=3600, + unit=UnitOfTime.SECONDS, + cluster_id=ThirdRealityMotionCluster.cluster_id, + translation_key="detection_interval", + fallback_name="Detection interval", + ) + .add_to_registry() +) diff --git a/zhaquirks/thirdreality/plug.py b/zhaquirks/thirdreality/plug.py new file mode 100644 index 0000000000..a3858d5faa --- /dev/null +++ b/zhaquirks/thirdreality/plug.py @@ -0,0 +1,38 @@ +"""Third Reality plug devices.""" + +from typing import Final + +from zigpy.quirks import CustomCluster +from zigpy.quirks.v2 import QuirkBuilder +import zigpy.types as t +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef + + +class ThirdRealityPlugCluster(CustomCluster): + """Third Reality's plug private cluster.""" + + cluster_id = 0xFF03 + + class AttributeDefs(BaseAttributeDefs): + """Define the attributes of a private cluster.""" + + reset_summation_delivered: Final = ZCLAttributeDef( + id=0x0000, + type=t.uint8_t, + is_manufacturer_specific=True, + ) + + +( + QuirkBuilder("Third Reality, Inc", "3RSP02028BZ") + .also_applies_to("Third Reality, Inc", "3RSPE01044BZ") + .replaces(ThirdRealityPlugCluster) + .write_attr_button( + attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name, + attribute_value=0x01, + cluster_id=ThirdRealityPlugCluster.cluster_id, + translation_key="reset_summation_delivered", + fallback_name="Reset summation delivered", + ) + .add_to_registry() +) diff --git a/zhaquirks/thirdreality/water_leak_sensor.py b/zhaquirks/thirdreality/water_leak_sensor.py new file mode 100644 index 0000000000..a8387d1903 --- /dev/null +++ b/zhaquirks/thirdreality/water_leak_sensor.py @@ -0,0 +1,52 @@ +"""Third Reality water leak devices.""" + +from typing import Final + +from zigpy.quirks import CustomCluster +from zigpy.quirks.v2 import QuirkBuilder +from zigpy.quirks.v2.homeassistant import UnitOfTime +import zigpy.types as t +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef + + +class ThirdRealityWaterLeakCluster(CustomCluster): + """Third Reality's water leak sensor private cluster.""" + + cluster_id = 0xFF01 + + class AttributeDefs(BaseAttributeDefs): + """Define the attributes of a private cluster.""" + + enable_siren: Final = ZCLAttributeDef( + id=0x0010, + type=t.uint8_t, + is_manufacturer_specific=True, + ) + + siren_time: Final = ZCLAttributeDef( + id=0x0011, + type=t.uint8_t, + is_manufacturer_specific=True, + ) + + +( + QuirkBuilder("Third Reality, Inc", "3RWS18BZ") + .replaces(ThirdRealityWaterLeakCluster) + .switch( + attribute_name=ThirdRealityWaterLeakCluster.AttributeDefs.enable_siren.name, + cluster_id=ThirdRealityWaterLeakCluster.cluster_id, + translation_key="enable_siren", + fallback_name="Enable siren", + ) + .number( + attribute_name=ThirdRealityWaterLeakCluster.AttributeDefs.siren_time.name, + min_value=0, + max_value=255, + unit=UnitOfTime.MINUTES, + cluster_id=ThirdRealityWaterLeakCluster.cluster_id, + translation_key="siren_time", + fallback_name="Siren time", + ) + .add_to_registry() +)