Skip to content

Commit d560032

Browse files
committed
Fix retrieval of reactive power
The data sourcing actor needs to know about the new metric. This commit exposes it, adds a trivial test and updates the release notes to do a hotfix right after this is merged. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 11baf07 commit d560032

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# Frequenz Python SDK Release Notes
22

3-
## Summary
4-
5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
11-
## New Features
12-
13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14-
153
## Bug Fixes
164

17-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
5+
- Fix getting reactive power from meters, inverters and EV chargers.

src/frequenz/sdk/actor/_data_sourcing/microgrid_api_source.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
3939
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
4040
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
41+
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
42+
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
43+
0
44+
],
45+
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
46+
1
47+
],
48+
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
49+
2
50+
],
4151
}
4252

4353
_BatteryDataMethods: dict[ComponentMetricId, Callable[[BatteryData], float]] = {
@@ -84,6 +94,16 @@
8494
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
8595
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
8696
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
97+
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
98+
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
99+
0
100+
],
101+
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
102+
1
103+
],
104+
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
105+
2
106+
],
87107
}
88108

89109
_EVChargerDataMethods: dict[ComponentMetricId, Callable[[EVChargerData], float]] = {
@@ -98,6 +118,16 @@
98118
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
99119
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
100120
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
121+
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
122+
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
123+
0
124+
],
125+
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
126+
1
127+
],
128+
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
129+
2
130+
],
101131
}
102132

103133

tests/actor/test_data_sourcing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ async def test_data_sourcing_actor(self) -> None:
6565
).new_receiver()
6666
await req_sender.send(active_power_request)
6767

68+
reactive_power_request = ComponentMetricRequest(
69+
"test-namespace", 4, ComponentMetricId.REACTIVE_POWER, None
70+
)
71+
reactive_power_recv = registry.get_or_create(
72+
Sample[Quantity], reactive_power_request.get_channel_name()
73+
).new_receiver()
74+
await req_sender.send(reactive_power_request)
75+
6876
soc_request = ComponentMetricRequest(
6977
"test-namespace", 9, ComponentMetricId.SOC, None
7078
)

0 commit comments

Comments
 (0)