Skip to content

Commit

Permalink
Add Third Reality plug, motion, water leak sensor (#3426)
Browse files Browse the repository at this point in the history
Co-authored-by: TheJulianJES <[email protected]>
  • Loading branch information
hwzolin and TheJulianJES authored Nov 27, 2024
1 parent abf208e commit 382dc33
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
40 changes: 40 additions & 0 deletions zhaquirks/thirdreality/motion_sensor.py
Original file line number Diff line number Diff line change
@@ -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()
)
38 changes: 38 additions & 0 deletions zhaquirks/thirdreality/plug.py
Original file line number Diff line number Diff line change
@@ -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()
)
52 changes: 52 additions & 0 deletions zhaquirks/thirdreality/water_leak_sensor.py
Original file line number Diff line number Diff line change
@@ -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()
)

0 comments on commit 382dc33

Please sign in to comment.