|
1 | | -"""Third Reality plug devices.""" |
2 | | - |
3 | | -from typing import Final |
4 | | - |
5 | | -from zigpy.quirks import CustomCluster |
6 | | -from zigpy.quirks.v2 import QuirkBuilder |
7 | | -import zigpy.types as t |
8 | | -from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef |
9 | | - |
10 | | - |
11 | | -class ThirdRealityPlugCluster(CustomCluster): |
12 | | - """Third Reality's plug private cluster.""" |
13 | | - |
14 | | - cluster_id = 0xFF03 |
15 | | - |
16 | | - class AttributeDefs(BaseAttributeDefs): |
17 | | - """Define the attributes of a private cluster.""" |
18 | | - |
19 | | - reset_summation_delivered: Final = ZCLAttributeDef( |
20 | | - id=0x0000, |
21 | | - type=t.uint8_t, |
22 | | - is_manufacturer_specific=True, |
23 | | - ) |
24 | | - |
25 | | - |
26 | | -( |
27 | | - QuirkBuilder("Third Reality, Inc", "3RSP02028BZ") |
28 | | - .also_applies_to("Third Reality, Inc", "3RSPE01044BZ") |
29 | | - .replaces(ThirdRealityPlugCluster) |
30 | | - .write_attr_button( |
31 | | - attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name, |
32 | | - attribute_value=0x01, |
33 | | - cluster_id=ThirdRealityPlugCluster.cluster_id, |
34 | | - translation_key="reset_summation_delivered", |
35 | | - fallback_name="Reset summation delivered", |
36 | | - ) |
37 | | - .add_to_registry() |
38 | | -) |
| 1 | +"""Third Reality plug devices.""" |
| 2 | + |
| 3 | +from typing import Final |
| 4 | + |
| 5 | +from zigpy.quirks import CustomCluster |
| 6 | +from zigpy.quirks.v2 import QuirkBuilder |
| 7 | +from zigpy.quirks.v2.homeassistant import UnitOfTime |
| 8 | +from zigpy.quirks.v2.homeassistant.number import NumberDeviceClass |
| 9 | +import zigpy.types as t |
| 10 | +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef |
| 11 | + |
| 12 | + |
| 13 | +class ThirdRealityPlugCluster(CustomCluster): |
| 14 | + """Third Reality's plug private cluster.""" |
| 15 | + |
| 16 | + cluster_id = 0xFF03 |
| 17 | + |
| 18 | + class AttributeDefs(BaseAttributeDefs): |
| 19 | + """Define the attributes of a private cluster.""" |
| 20 | + |
| 21 | + # reset the accumulated power of the plug |
| 22 | + reset_summation_delivered: Final = ZCLAttributeDef( |
| 23 | + id=0x0000, |
| 24 | + type=t.uint8_t, |
| 25 | + is_manufacturer_specific=True, |
| 26 | + ) |
| 27 | + |
| 28 | + # turn off delay |
| 29 | + on_to_off_delay: Final = ZCLAttributeDef( |
| 30 | + id=0x0001, |
| 31 | + type=t.uint16_t, |
| 32 | + is_manufacturer_specific=True, |
| 33 | + ) |
| 34 | + |
| 35 | + # turn on delay |
| 36 | + off_to_on_delay: Final = ZCLAttributeDef( |
| 37 | + id=0x0002, |
| 38 | + type=t.uint16_t, |
| 39 | + is_manufacturer_specific=True, |
| 40 | + ) |
| 41 | + |
| 42 | + |
| 43 | +# single outlet plugs |
| 44 | +( |
| 45 | + QuirkBuilder("Third Reality, Inc", "3RSP02028BZ") |
| 46 | + .applies_to("Third Reality, Inc", "3RSPE01044BZ") |
| 47 | + .applies_to("Third Reality, Inc", "3RSPU01080Z") |
| 48 | + .applies_to("Third Reality, Inc", "3RSP02064Z") |
| 49 | + .applies_to("Third Reality, Inc", "3RSPE02065Z") |
| 50 | + .replaces(ThirdRealityPlugCluster) |
| 51 | + .write_attr_button( |
| 52 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name, |
| 53 | + attribute_value=0x01, # 1 reset summation delivered |
| 54 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 55 | + translation_key="reset_summation_delivered", |
| 56 | + fallback_name="Reset summation delivered", |
| 57 | + ) |
| 58 | + .number( |
| 59 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name, |
| 60 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 61 | + endpoint_id=1, |
| 62 | + min_value=0, |
| 63 | + max_value=65535, |
| 64 | + mode="box", |
| 65 | + unit=UnitOfTime.SECONDS, |
| 66 | + device_class=NumberDeviceClass.DURATION, |
| 67 | + translation_key="turn_off_delay", |
| 68 | + fallback_name="Turn off delay", |
| 69 | + ) |
| 70 | + .number( |
| 71 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name, |
| 72 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 73 | + endpoint_id=1, |
| 74 | + min_value=0, |
| 75 | + max_value=65535, |
| 76 | + mode="box", |
| 77 | + unit=UnitOfTime.SECONDS, |
| 78 | + device_class=NumberDeviceClass.DURATION, |
| 79 | + translation_key="turn_on_delay", |
| 80 | + fallback_name="Turn on delay", |
| 81 | + ) |
| 82 | + .add_to_registry() |
| 83 | +) |
| 84 | + |
| 85 | +# double outlet plugs |
| 86 | +( |
| 87 | + QuirkBuilder("Third Reality, Inc", "3RDP01072Z") |
| 88 | + .applies_to("Third Reality, Inc", "3RWP01073Z") |
| 89 | + .replaces(ThirdRealityPlugCluster, endpoint_id=1) |
| 90 | + .replaces(ThirdRealityPlugCluster, endpoint_id=2) |
| 91 | + .write_attr_button( |
| 92 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name, |
| 93 | + attribute_value=0x01, # 1 reset summation delivered |
| 94 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 95 | + endpoint_id=1, |
| 96 | + translation_key="reset_summation_delivered_left", |
| 97 | + fallback_name="Reset left summation delivered", # ep1 is left |
| 98 | + ) |
| 99 | + .write_attr_button( |
| 100 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.reset_summation_delivered.name, |
| 101 | + attribute_value=0x01, |
| 102 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 103 | + endpoint_id=2, |
| 104 | + translation_key="reset_summation_delivered_right", |
| 105 | + fallback_name="Reset right summation delivered", # ep2 is right |
| 106 | + ) |
| 107 | + .number( |
| 108 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name, |
| 109 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 110 | + endpoint_id=1, |
| 111 | + min_value=0, |
| 112 | + max_value=65535, |
| 113 | + mode="box", |
| 114 | + unit=UnitOfTime.SECONDS, |
| 115 | + device_class=NumberDeviceClass.DURATION, |
| 116 | + translation_key="turn_off_delay_left", |
| 117 | + fallback_name="Turn off delay left", |
| 118 | + ) |
| 119 | + .number( |
| 120 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.on_to_off_delay.name, |
| 121 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 122 | + endpoint_id=2, |
| 123 | + min_value=0, |
| 124 | + max_value=65535, |
| 125 | + mode="box", |
| 126 | + unit=UnitOfTime.SECONDS, |
| 127 | + device_class=NumberDeviceClass.DURATION, |
| 128 | + translation_key="turn_off_delay_right", |
| 129 | + fallback_name="Turn off delay right", |
| 130 | + ) |
| 131 | + .number( |
| 132 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name, |
| 133 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 134 | + endpoint_id=1, |
| 135 | + min_value=0, |
| 136 | + max_value=65535, |
| 137 | + mode="box", |
| 138 | + unit=UnitOfTime.SECONDS, |
| 139 | + device_class=NumberDeviceClass.DURATION, |
| 140 | + translation_key="turn_on_delay_left", |
| 141 | + fallback_name="Turn on delay left", |
| 142 | + ) |
| 143 | + .number( |
| 144 | + attribute_name=ThirdRealityPlugCluster.AttributeDefs.off_to_on_delay.name, |
| 145 | + cluster_id=ThirdRealityPlugCluster.cluster_id, |
| 146 | + endpoint_id=2, |
| 147 | + min_value=0, |
| 148 | + max_value=65535, |
| 149 | + mode="box", |
| 150 | + unit=UnitOfTime.SECONDS, |
| 151 | + device_class=NumberDeviceClass.DURATION, |
| 152 | + translation_key="turn_on_delay_right", |
| 153 | + fallback_name="Turn on delay right", |
| 154 | + ) |
| 155 | + .add_to_registry() |
| 156 | +) |
0 commit comments