-
Notifications
You must be signed in to change notification settings - Fork 878
Add Third Reality dual plug and single plug settings #4109
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
base: dev
Are you sure you want to change the base?
Changes from 60 commits
f04cc8c
ede63c1
ce0a7fb
5fa93b2
bb80eea
50e524f
59c7701
207156b
4ac23ee
463ad2f
7156188
45d3744
87a5218
503169a
bded2c7
2e84798
62dcafd
a22f4e9
5cca1a7
089b76e
ed10c06
2314b00
697e43f
1e99c2b
316640a
1d3de26
31ca101
0d83b67
cff8d6c
1146892
76351ca
1c7fab5
2e64798
a7dda09
cfbf51b
4e677f8
dc7d5ce
ae68c82
e776deb
a224af7
976e071
e386bf9
889e38a
c08859b
40e0322
ddb3a63
083c36b
517e1fe
55052ff
dcc326a
4c01e11
e2dee3e
4cbb2d6
6fe164a
17a60dc
935bbc1
5986e93
ffd8660
9b4f35e
534e1ff
19a74f0
377c1c7
bed3146
0af9494
3307bbb
d4951f6
640321b
bfe7979
1ab9e50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
) |
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") | ||
.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 | ||
|
||
) | ||
.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_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", | ||
) | ||
|
||
.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() | ||
) |
There was a problem hiding this comment.
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 usingapplies_to
in most quirks.