Skip to content
Open
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
f04cc8c
add 3r waterleak py
jintj Aug 30, 2024
ede63c1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
ce0a7fb
Update waterleak.py
3reality-support Aug 30, 2024
5fa93b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
bb80eea
Update waterleak.py
3reality-support Aug 30, 2024
50e524f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
59c7701
Update waterleak.py
3reality-support Aug 30, 2024
207156b
Update waterleak.py
3reality-support Aug 30, 2024
4ac23ee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
463ad2f
add 3r project py
jintj Aug 30, 2024
7156188
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
45d3744
Update door.py
3reality-support Aug 30, 2024
87a5218
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
503169a
add 3r project py
jintj Aug 30, 2024
bded2c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
2e84798
Update garage.py
3reality-support Aug 30, 2024
62dcafd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2024
a22f4e9
Rename temperature_humidity and soil.py to temperature_humidity_and_s…
3reality-support Aug 30, 2024
5cca1a7
Merge branch 'zigpy:dev' into test
3reality-support Sep 5, 2024
089b76e
Merge branch 'zigpy:dev' into test
3reality-support Nov 27, 2024
ed10c06
merge
jintj Nov 27, 2024
2314b00
Merge branch 'test' into dev
jintj Nov 27, 2024
697e43f
Merge branch 'zigpy:dev' into dev
3reality-support Dec 19, 2024
1e99c2b
Merge branch 'zigpy:dev' into dev
3reality-support Jan 10, 2025
316640a
update
jintj Jan 10, 2025
1d3de26
update
jintj Jan 10, 2025
31ca101
update
jintj Jan 10, 2025
0d83b67
update
jintj Jan 10, 2025
cff8d6c
update
jintj Jan 10, 2025
1146892
update
jintj Jan 10, 2025
76351ca
update
jintj Jan 10, 2025
1c7fab5
update
jintj Jan 10, 2025
2e64798
Apply pre-commit auto fixes
pre-commit-ci[bot] Jan 10, 2025
a7dda09
update
jintj Jan 10, 2025
cfbf51b
Merge branch 'dev' of https://github.com/3reality-support/zha-device-…
jintj Jan 10, 2025
4e677f8
Merge branch 'zigpy:dev' into dev
3reality-support Feb 11, 2025
dc7d5ce
Merge branch 'zigpy:dev' into dev
3reality-support Apr 23, 2025
ae68c82
Merge branch 'zigpy:dev' into dev
3reality-support May 27, 2025
e776deb
updatye
jintj Jun 6, 2025
a224af7
update
jintj Jun 6, 2025
976e071
update
jintj Jun 6, 2025
e386bf9
updaye
jintj Jun 6, 2025
889e38a
update
jintj Jun 6, 2025
c08859b
Apply pre-commit auto fixes
pre-commit-ci[bot] Jun 6, 2025
40e0322
update
jintj Jun 6, 2025
ddb3a63
Merge branch 'dev' of https://github.com/3reality-support/zha-device-…
jintj Jun 6, 2025
083c36b
update
jintj Jun 6, 2025
517e1fe
update
jintj Jun 6, 2025
55052ff
Merge branch 'zigpy:dev' into dev
3reality-support Jun 24, 2025
dcc326a
update
jintj Jun 24, 2025
4c01e11
Apply pre-commit auto fixes
pre-commit-ci[bot] Jun 24, 2025
e2dee3e
update
jintj Jun 24, 2025
4cbb2d6
Merge branch 'dev' of https://github.com/3reality-support/zha-device-…
jintj Jun 24, 2025
6fe164a
Apply pre-commit auto fixes
pre-commit-ci[bot] Jun 24, 2025
17a60dc
Merge branch 'zigpy:dev' into dev
3reality-support Jun 26, 2025
935bbc1
update
jintj Jun 26, 2025
5986e93
Apply pre-commit auto fixes
pre-commit-ci[bot] Jun 26, 2025
ffd8660
update
jintj Jun 26, 2025
9b4f35e
Merge branch 'dev' of https://github.com/3reality-support/zha-device-…
jintj Jun 26, 2025
534e1ff
update
jintj Jun 26, 2025
19a74f0
Merge branch 'zigpy:dev' into dev
3reality-support Jul 14, 2025
377c1c7
update
jintj Jul 14, 2025
bed3146
update
jintj Jul 14, 2025
0af9494
update
jintj Jul 14, 2025
3307bbb
Merge branch 'zigpy:dev' into dev
3reality-support Sep 4, 2025
d4951f6
update plug_dual translation_key
jintj Sep 4, 2025
640321b
update
jintj Sep 4, 2025
bfe7979
Merge branch 'zigpy:dev' into dev
3reality-support Sep 20, 2025
1ab9e50
Merge branch 'zigpy:dev' into dev
3reality-support Sep 25, 2025
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
122 changes: 84 additions & 38 deletions zhaquirks/thirdreality/plug.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,84 @@
"""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()
)
"""Third Reality plug devices."""

from typing import Final

from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import QuirkBuilder
from zigpy.quirks.v2.homeassistant import UnitOfTime
from zigpy.quirks.v2.homeassistant.number import NumberDeviceClass
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 the accumulated power of the plug
reset_summation_delivered: Final = ZCLAttributeDef(
id=0x0000,
type=t.uint8_t,
is_manufacturer_specific=True,
)

# turn off delay
on_to_off_delay: Final = ZCLAttributeDef(
id=0x0001,
type=t.uint16_t,
is_manufacturer_specific=True,
)

# turn on delay
off_to_on_delay: Final = ZCLAttributeDef(
id=0x0002,
type=t.uint16_t,
is_manufacturer_specific=True,
)


(
QuirkBuilder("Third Reality, Inc", "3RSP02028BZ")
.also_applies_to("Third Reality, Inc", "3RSPE01044BZ")
.also_applies_to("Third Reality, Inc", "3RSPU01080Z")
.also_applies_to("Third Reality, Inc", "3RSP02064Z")
.also_applies_to("Third Reality, Inc", "3RSPE02065Z")
.replaces(ThirdRealityPlugCluster)
.write_attr_button(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name,
attribute_value=0x01, # 1 reset summation delivered
cluster_id=ThirdRealityPlugCluster.cluster_id,
translation_key="reset_summation_delivered",
fallback_name="Reset summation delivered",
)
.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=1,
min_value=0,
max_value=65535,
step=1,
mode="box",
unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="on_to_off_delay",
fallback_name="Turn off delay",
)
.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=1,
min_value=0,
max_value=65535,
step=1,
mode="box",
unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="off_to_on_delay",
fallback_name="Turn on delay",
)
.add_to_registry()
)
117 changes: 117 additions & 0 deletions zhaquirks/thirdreality/plug_dual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Third Reality dual plug devices."""

from typing import Final

from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import QuirkBuilder
from zigpy.quirks.v2.homeassistant import UnitOfTime
from zigpy.quirks.v2.homeassistant.number import NumberDeviceClass
import zigpy.types as t
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef


class ThirdRealityPlugCluster(CustomCluster):
"""Third Reality's dual plug private cluster."""

cluster_id = 0xFF03

class AttributeDefs(BaseAttributeDefs):
"""Define the attributes of a private cluster."""

# reset the accumulated power of the plug
reset_summation_delivered: Final = ZCLAttributeDef(
id=0x0000,
type=t.uint8_t,
is_manufacturer_specific=True,
)

# turn off delay
on_to_off_delay: Final = ZCLAttributeDef(
id=0x0001,
type=t.uint16_t,
is_manufacturer_specific=True,
)

# turn on delay
off_to_on_delay: Final = ZCLAttributeDef(
id=0x0002,
type=t.uint16_t,
is_manufacturer_specific=True,
)


(
QuirkBuilder("Third Reality, Inc", "3RDP01072Z")
.also_applies_to("Third Reality, Inc", "3RWP01073Z")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use applies_to. Both do the same, but we've switched to just using applies_to in most quirks.

.replaces(ThirdRealityPlugCluster, endpoint_id=1)
.replaces(ThirdRealityPlugCluster, endpoint_id=2)
.write_attr_button(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name,
attribute_value=0x01, # 1 reset summation delivered
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=1,
translation_key="reset_summation_delivered_ep1",
fallback_name="Reset left summation delivered", # ep1 is left
)
.write_attr_button(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name,
attribute_value=0x01,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=2,
translation_key="reset_summation_delivered_ep2",
fallback_name="Reset right summation delivered ep2", # ep2 is right
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is similar to my previous comment, let's just include either left/right or 1/2, not both and not something abbreviated like "ep2".

)
.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=1,
min_value=0,
max_value=65535,
step=1,
mode="box",
Copy link
Collaborator

Choose a reason for hiding this comment

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

mode=box is fine to keep, but we don't actually set that mode in ZHA yet.
So, it's expected that this does nothing (for now). There's an open issue in the ZHA repo about this.

unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="on_to_off_delay_ep1",
fallback_name="Turn off delay",
)
.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=2,
min_value=0,
max_value=65535,
step=1,
mode="box",
unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="on_to_off_delay_ep2",
fallback_name="Turn off delay",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The fallback_name will be used as the English translation for the translation_key when this makes its way into HA. Here, the translation keys are different for the two endpoints, but the fallback name is the same.
We should just change the fallback_name to either be "Turn off delay 1" and "Turn off delay 2" or be something like "Turn off delay left" and "Turn off delay right".

In the future, we'll try and add a postfix if there are entities named in the same way on multiple endpoints. For now, it's fine to explicitly make the translation key and fallback name different. Other integrations in HA also do this.

Please also adjust all other occurrences.

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean that the translation_key for ep1 and ep2 can be the same.But there was an error on my end
3129505c582599ab562f5ca2761bc44

Comment on lines 64 to 87
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, have you checked that the two entities each for the dual plug both show up in HA?
I thought the unique IDs might conflict, as they're just based on the attribute name, but we might also include the endpoint. I'd have to check.

If both appear, this is fine. Otherwise, you can include unique_id_suffix="on_to_off_delay_1" (and _2) for the entities to assign a different UID.

.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=1,
min_value=0,
max_value=65535,
step=1,
mode="box",
unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="off_to_on_delay_ep1",
fallback_name="Turn on delay",
)
.number(
attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name,
cluster_id=ThirdRealityPlugCluster.cluster_id,
endpoint_id=2,
min_value=0,
max_value=65535,
step=1,
mode="box",
unit=UnitOfTime.SECONDS,
device_class=NumberDeviceClass.DURATION,
translation_key="off_to_on_delay_ep2",
fallback_name="Turn on delay",
)
.add_to_registry()
)
Loading