Skip to content

Commit

Permalink
Fix retrieval of reactive power
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
llucax committed Apr 12, 2024
1 parent 11baf07 commit d560032
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
14 changes: 1 addition & 13 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# Frequenz Python SDK Release Notes

## Summary

<!-- Here goes a general summary of what this release is about -->

## Upgrading

<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->

## New Features

<!-- Here goes the main new features and examples or instructions on how to use them -->

## Bug Fixes

<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
- Fix getting reactive power from meters, inverters and EV chargers.
30 changes: 30 additions & 0 deletions src/frequenz/sdk/actor/_data_sourcing/microgrid_api_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
0
],
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
1
],
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
2
],
}

_BatteryDataMethods: dict[ComponentMetricId, Callable[[BatteryData], float]] = {
Expand Down Expand Up @@ -84,6 +94,16 @@
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
0
],
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
1
],
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
2
],
}

_EVChargerDataMethods: dict[ComponentMetricId, Callable[[EVChargerData], float]] = {
Expand All @@ -98,6 +118,16 @@
ComponentMetricId.VOLTAGE_PHASE_2: lambda msg: msg.voltage_per_phase[1],
ComponentMetricId.VOLTAGE_PHASE_3: lambda msg: msg.voltage_per_phase[2],
ComponentMetricId.FREQUENCY: lambda msg: msg.frequency,
ComponentMetricId.REACTIVE_POWER: lambda msg: msg.reactive_power,
ComponentMetricId.REACTIVE_POWER_PHASE_1: lambda msg: msg.reactive_power_per_phase[
0
],
ComponentMetricId.REACTIVE_POWER_PHASE_2: lambda msg: msg.reactive_power_per_phase[
1
],
ComponentMetricId.REACTIVE_POWER_PHASE_3: lambda msg: msg.reactive_power_per_phase[
2
],
}


Expand Down
8 changes: 8 additions & 0 deletions tests/actor/test_data_sourcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ async def test_data_sourcing_actor(self) -> None:
).new_receiver()
await req_sender.send(active_power_request)

reactive_power_request = ComponentMetricRequest(
"test-namespace", 4, ComponentMetricId.REACTIVE_POWER, None
)
reactive_power_recv = registry.get_or_create(
Sample[Quantity], reactive_power_request.get_channel_name()
).new_receiver()
await req_sender.send(reactive_power_request)

soc_request = ComponentMetricRequest(
"test-namespace", 9, ComponentMetricId.SOC, None
)
Expand Down

0 comments on commit d560032

Please sign in to comment.