Skip to content

Commit e54f142

Browse files
committed
Update inverter component data to extract AC current values
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 300544d commit e54f142

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ class InverterData(ComponentData):
231231
-ve current means supply into the grid.
232232
"""
233233

234+
current_per_phase: tuple[float, float, float]
235+
"""AC current in Amperes (A) for phase/line 1,2 and 3 respectively.
236+
+ve current means consumption, away from the grid.
237+
-ve current means supply into the grid.
238+
"""
239+
234240
# pylint: disable=line-too-long
235241
active_power_inclusion_lower_bound: float
236242
"""Lower inclusion bound for inverter power in watts.
@@ -301,6 +307,11 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData:
301307
component_id=raw.id,
302308
timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc),
303309
active_power=raw.inverter.data.ac.power_active.value,
310+
current_per_phase=(
311+
raw.meter.data.ac.phase_1.current.value,
312+
raw.meter.data.ac.phase_2.current.value,
313+
raw.meter.data.ac.phase_3.current.value,
314+
),
304315
active_power_inclusion_lower_bound=raw_power.system_inclusion_bounds.lower,
305316
active_power_exclusion_lower_bound=raw_power.system_exclusion_bounds.lower,
306317
active_power_inclusion_upper_bound=raw_power.system_inclusion_bounds.upper,

tests/utils/component_data_wrapper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __init__( # pylint: disable=too-many-arguments
101101
component_id: int,
102102
timestamp: datetime,
103103
active_power: float = math.nan,
104+
current_per_phase: tuple[float, float, float] | None = None,
104105
active_power_inclusion_lower_bound: float = math.nan,
105106
active_power_exclusion_lower_bound: float = math.nan,
106107
active_power_inclusion_upper_bound: float = math.nan,
@@ -120,6 +121,11 @@ def __init__( # pylint: disable=too-many-arguments
120121
component_id=component_id,
121122
timestamp=timestamp,
122123
active_power=active_power,
124+
current_per_phase=(
125+
current_per_phase
126+
if current_per_phase
127+
else (math.nan, math.nan, math.nan)
128+
),
123129
active_power_inclusion_lower_bound=active_power_inclusion_lower_bound,
124130
active_power_exclusion_lower_bound=active_power_exclusion_lower_bound,
125131
active_power_inclusion_upper_bound=active_power_inclusion_upper_bound,

0 commit comments

Comments
 (0)