Skip to content

Commit ef80cf2

Browse files
committed
Added sensors
1 parent 969a32e commit ef80cf2

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

zhaquirks/lixee/zlinky.py

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
"""Quirk for ZLinky_TIC."""
22

3-
from zha.units import UnitOfApparentPower
3+
from zha.units import UnitOfApparentPower, UnitOfElectricCurrent
44
from zigpy.quirks import CustomCluster
55
from zigpy.quirks.v2 import EntityPlatform, EntityType, QuirkBuilder
66
import zigpy.types as t
7+
from zigpy.zcl.clusters.general import Basic
78
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
89
from zigpy.zcl.clusters.smartenergy import Metering
910

1011
from zhaquirks.lixee import LIXEE, ZLINKY_MANUFACTURER_CLUSTER_ID
1112

1213

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+
1325
class ZLinkyTICTarif(t.enum8):
1426
"""ZLinkyTICTarif tarif enumeration."""
1527

@@ -141,30 +153,80 @@ class ZLinkyTICMetering(CustomCluster, Metering):
141153
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
142154

143155

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+
144165
(
145166
QuirkBuilder(LIXEE, "ZLinky_TIC")
146167
.replaces(ZLinkyTICMetering)
168+
.replaces(ZLinkyTICElectricalMeasurement)
147169
.replaces(ZLinkyTICManufacturerCluster)
148170
.sensor(
149171
ZLinkyTICMetering.AttributeDefs.site_id.name,
150172
ZLinkyTICMetering.cluster_id,
151-
translation_key="atmospheric_pressure",
152173
fallback_name="PRN",
153174
)
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+
)
154185
.sensor(
155186
ElectricalMeasurement.AttributeDefs.active_power_max.name,
156187
ElectricalMeasurement.cluster_id,
157188
translation_key="Power Max",
158189
unit=UnitOfApparentPower.VOLT_AMPERE,
159-
# device_class=SensorDeviceClass.APPARENT_POWER,
160190
fallback_name="Max Power",
161191
)
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+
# )
162215
.enum(
163216
"std_current_tariff_index_number",
164217
ZLinkyTICTarif,
165218
ZLinkyTICManufacturerCluster.cluster_id,
166219
entity_type=EntityType.STANDARD,
167220
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",
168230
)
169231
.add_to_registry()
170232
)

0 commit comments

Comments
 (0)