Skip to content

Commit ea0f330

Browse files
Fetch AC active power per phase from components
Fetch AC active power from meter, inverter and EV charger components for phase/line 1,2 and 3 respectively. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 585b79d commit ea0f330

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/frequenz/sdk/microgrid/component/_component_data.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class MeterData(ComponentData):
6868
-ve current means supply into the grid.
6969
"""
7070

71+
active_power_per_phase: tuple[float, float, float]
72+
"""The AC active power for phase/line 1,2 and 3 respectively."""
73+
7174
current_per_phase: tuple[float, float, float]
7275
"""AC current in Amperes (A) for phase/line 1,2 and 3 respectively.
7376
+ve current means consumption, away from the grid.
@@ -96,6 +99,11 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> MeterData:
9699
component_id=raw.id,
97100
timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc),
98101
active_power=raw.meter.data.ac.power_active.value,
102+
active_power_per_phase=(
103+
raw.meter.data.ac.phase_1.power_active.value,
104+
raw.meter.data.ac.phase_2.power_active.value,
105+
raw.meter.data.ac.phase_3.power_active.value,
106+
),
99107
current_per_phase=(
100108
raw.meter.data.ac.phase_1.current.value,
101109
raw.meter.data.ac.phase_2.current.value,
@@ -231,6 +239,9 @@ class InverterData(ComponentData):
231239
-ve current means supply into the grid.
232240
"""
233241

242+
active_power_per_phase: tuple[float, float, float]
243+
"""The AC active power for phase/line 1, 2 and 3 respectively."""
244+
234245
current_per_phase: tuple[float, float, float]
235246
"""AC current in Amperes (A) for phase/line 1, 2 and 3 respectively.
236247
+ve current means consumption, away from the grid.
@@ -312,6 +323,11 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData:
312323
component_id=raw.id,
313324
timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc),
314325
active_power=raw.inverter.data.ac.power_active.value,
326+
active_power_per_phase=(
327+
raw.inverter.data.ac.phase_1.power_active.value,
328+
raw.inverter.data.ac.phase_2.power_active.value,
329+
raw.inverter.data.ac.phase_3.power_active.value,
330+
),
315331
current_per_phase=(
316332
raw.inverter.data.ac.phase_1.current.value,
317333
raw.inverter.data.ac.phase_2.current.value,
@@ -345,6 +361,9 @@ class EVChargerData(ComponentData):
345361
-ve current means supply into the grid.
346362
"""
347363

364+
active_power_per_phase: tuple[float, float, float]
365+
"""The AC active power for phase/line 1,2 and 3 respectively."""
366+
348367
current_per_phase: tuple[float, float, float]
349368
"""AC current in Amperes (A) for phase/line 1,2 and 3 respectively.
350369
+ve current means consumption, away from the grid.
@@ -424,6 +443,11 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> EVChargerData:
424443
component_id=raw.id,
425444
timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc),
426445
active_power=raw_power.value,
446+
active_power_per_phase=(
447+
raw.ev_charger.data.ac.phase_1.power_active.value,
448+
raw.ev_charger.data.ac.phase_2.power_active.value,
449+
raw.ev_charger.data.ac.phase_3.power_active.value,
450+
),
427451
current_per_phase=(
428452
raw.ev_charger.data.ac.phase_1.current.value,
429453
raw.ev_charger.data.ac.phase_2.current.value,

0 commit comments

Comments
 (0)