|
1 | 1 | """Quirk for ZLinky_TIC."""
|
2 | 2 |
|
3 |
| -from zha.units import UnitOfApparentPower |
| 3 | +from zha.units import UnitOfApparentPower, UnitOfElectricCurrent |
4 | 4 | from zigpy.quirks import CustomCluster
|
5 | 5 | from zigpy.quirks.v2 import EntityPlatform, EntityType, QuirkBuilder
|
6 | 6 | import zigpy.types as t
|
| 7 | +from zigpy.zcl.clusters.general import Basic |
7 | 8 | from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
|
8 | 9 | from zigpy.zcl.clusters.smartenergy import Metering
|
9 | 10 |
|
10 | 11 | from zhaquirks.lixee import LIXEE, ZLINKY_MANUFACTURER_CLUSTER_ID
|
11 | 12 |
|
12 | 13 |
|
| 14 | +class ZLinkyTICModeIdentifier(t.enum8): |
| 15 | + """ZLinkyTICTarif tarif enumeration.""" |
| 16 | + |
| 17 | + historique_monophase = 0 |
| 18 | + standard_monophase = 1 |
| 19 | + historique_triphase = 2 |
| 20 | + standard_triphase = 3 |
| 21 | + standard_monophase_producteur = 5 |
| 22 | + standard_triphase_producteur = 7 |
| 23 | + |
| 24 | + |
13 | 25 | class ZLinkyTICTarif(t.enum8):
|
14 | 26 | """ZLinkyTICTarif tarif enumeration."""
|
15 | 27 |
|
@@ -141,30 +153,80 @@ class ZLinkyTICMetering(CustomCluster, Metering):
|
141 | 153 | _CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
|
142 | 154 |
|
143 | 155 |
|
| 156 | +class ZLinkyTICElectricalMeasurement(CustomCluster, ElectricalMeasurement): |
| 157 | + """ZLinky_TIC custom lectricalMeasurement cluster.""" |
| 158 | + |
| 159 | + attributes = ElectricalMeasurement.attributes.copy() |
| 160 | + |
| 161 | + attributes[0x0908] = ("rms_current_p2", t.uint16_t, True) |
| 162 | + attributes[0x0A08] = ("rms_current_p3", t.uint16_t, True) |
| 163 | + |
| 164 | + |
144 | 165 | (
|
145 | 166 | QuirkBuilder(LIXEE, "ZLinky_TIC")
|
146 | 167 | .replaces(ZLinkyTICMetering)
|
| 168 | + .replaces(ZLinkyTICElectricalMeasurement) |
147 | 169 | .replaces(ZLinkyTICManufacturerCluster)
|
148 | 170 | .sensor(
|
149 | 171 | ZLinkyTICMetering.AttributeDefs.site_id.name,
|
150 | 172 | ZLinkyTICMetering.cluster_id,
|
151 |
| - translation_key="atmospheric_pressure", |
152 | 173 | fallback_name="PRN",
|
153 | 174 | )
|
| 175 | + .sensor( |
| 176 | + Basic.AttributeDefs.model.name, |
| 177 | + Basic.cluster_id, |
| 178 | + fallback_name="Model", |
| 179 | + ) |
| 180 | + .sensor( |
| 181 | + ZLinkyTICMetering.AttributeDefs.meter_serial_number.name, |
| 182 | + ZLinkyTICMetering.cluster_id, |
| 183 | + fallback_name="Serial Number", |
| 184 | + ) |
154 | 185 | .sensor(
|
155 | 186 | ElectricalMeasurement.AttributeDefs.active_power_max.name,
|
156 | 187 | ElectricalMeasurement.cluster_id,
|
157 | 188 | translation_key="Power Max",
|
158 | 189 | unit=UnitOfApparentPower.VOLT_AMPERE,
|
159 |
| - # device_class=SensorDeviceClass.APPARENT_POWER, |
160 | 190 | fallback_name="Max Power",
|
161 | 191 | )
|
| 192 | + .sensor( |
| 193 | + ZLinkyTICElectricalMeasurement.AttributeDefs.rms_current.name, |
| 194 | + ZLinkyTICElectricalMeasurement.cluster_id, |
| 195 | + unit=UnitOfElectricCurrent.AMPERE, |
| 196 | + fallback_name="Current Phase 1", |
| 197 | + ) |
| 198 | + .sensor( |
| 199 | + ZLinkyTICElectricalMeasurement.AttributeDefs.rms_current_p2.name, |
| 200 | + ZLinkyTICElectricalMeasurement.cluster_id, |
| 201 | + unit=UnitOfElectricCurrent.AMPERE, |
| 202 | + fallback_name="Current Phase 2", |
| 203 | + ) |
| 204 | + .sensor( |
| 205 | + ZLinkyTICElectricalMeasurement.AttributeDefs.rms_current_p3.name, |
| 206 | + ZLinkyTICElectricalMeasurement.cluster_id, |
| 207 | + unit=UnitOfElectricCurrent.AMPERE, |
| 208 | + fallback_name="Current Phase 3", |
| 209 | + ) |
| 210 | + # .sensor( |
| 211 | + # ZLinkyTICManufacturerCluster.AttributeDefs.std_current_supplier_price_description.name, |
| 212 | + # ZLinkyTICManufacturerCluster.cluster_id, |
| 213 | + # fallback_name="Tariff", |
| 214 | + # ) |
162 | 215 | .enum(
|
163 | 216 | "std_current_tariff_index_number",
|
164 | 217 | ZLinkyTICTarif,
|
165 | 218 | ZLinkyTICManufacturerCluster.cluster_id,
|
166 | 219 | entity_type=EntityType.STANDARD,
|
167 | 220 | entity_platform=EntityPlatform.SENSOR,
|
| 221 | + fallback_name="Tariff", |
| 222 | + ) |
| 223 | + .enum( |
| 224 | + "linky_mode", |
| 225 | + ZLinkyTICModeIdentifier, |
| 226 | + ZLinkyTICManufacturerCluster.cluster_id, |
| 227 | + entity_type=EntityType.STANDARD, |
| 228 | + entity_platform=EntityPlatform.SENSOR, |
| 229 | + fallback_name="Linky Mode", |
168 | 230 | )
|
169 | 231 | .add_to_registry()
|
170 | 232 | )
|
0 commit comments