Skip to content

Commit e71fd32

Browse files
Fix PV inverters power distribution (#1028)
To exclude PV inverters that haven't sent any data since startup. The power distributor crashed because it tried to get data from a component that had no data. Note that this is port of a patch-fix that was released in v1.0.0-rc602, but I have slightly changed some log messages as this was done in a rush.
2 parents d4df51d + 08364d6 commit e71fd32

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

RELEASE_NOTES.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
## Upgrading
88

99
- The `frequenz.sdk.microgrid.*_pool` methods has been renamed to `new_*_pool`, to make it explicit that they create new instances of the pool classes.
10-
+ `battery_pool` -> `new_battery_pool`
11-
+ `ev_charger_pool` -> `new_ev_charger_pool`
12-
+ `pv_pool` -> `new_pv_pool`
10+
- `battery_pool` -> `new_battery_pool`
11+
- `ev_charger_pool` -> `new_ev_charger_pool`
12+
- `pv_pool` -> `new_pv_pool`
1313

1414
- The following component metric streams have been renamed to clarify that they stream per-phase values:
15-
+ `frequenz.sdk.microgrid.`
16-
* `voltage` -> `voltage_per_phase`
17-
* `grid.current` -> `grid.current_per_phase`
18-
* `ev_charger_pool.current` -> `ev_charger_pool.current_per_phase`
15+
- `frequenz.sdk.microgrid.`
16+
- `voltage` -> `voltage_per_phase`
17+
- `grid.current` -> `grid.current_per_phase`
18+
- `ev_charger_pool.current` -> `ev_charger_pool.current_per_phase`
1919

20-
* Passing a `request_timeout` in calls to `*_pool.propose_power` is no longer supported. It may be specified at application startup, through the new optional `api_power_request_timeout` parameter in the `microgrid.initialize()` method.
20+
- Passing a `request_timeout` in calls to `*_pool.propose_power` is no longer supported. It may be specified at application startup, through the new optional `api_power_request_timeout` parameter in the `microgrid.initialize()` method.
2121

2222
- Power distribution results are no longer available through the `power_status` streams in the `*Pool`s. They can now be accessed as a stream from a separate property `power_distribution_results`, which is available from all the `*Pool`s.
2323

@@ -42,3 +42,4 @@
4242
- Fixed typing ambiguities when building composite formulas on streaming data.
4343
- Fixed a bug that was causing the `PowerDistributor` to exit if power requests to PV inverters or EV chargers timeout.
4444
- Fix handling of cancelled tasks in the data sourcing and resampling actor.
45+
- Fix PV power distribution excluding inverters that haven't sent any data since startup.

src/frequenz/sdk/actor/power_distributing/_component_managers/_pv_inverter_manager/_pv_inverter_manager.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,19 @@ async def distribute_power(self, request: Request) -> None:
121121
raise ValueError(
122122
"Cannot distribute power to PV inverters without any inverters"
123123
)
124-
working_components = list(
125-
self._component_pool_status_tracker.get_working_components(
126-
request.component_ids
127-
)
128-
)
124+
125+
working_components: list[int] = []
126+
for inv_id in self._component_pool_status_tracker.get_working_components(
127+
request.component_ids
128+
):
129+
if self._component_data_caches[inv_id].has_value():
130+
working_components.append(inv_id)
131+
else:
132+
_logger.warning(
133+
"Excluding PV inverter %s from power distribution due to "
134+
"lack of data since startup.",
135+
inv_id,
136+
)
129137

130138
# When sorting by lower bounds, which are negative for PV inverters, we have to
131139
# reverse the order, so that the inverters with the higher bounds i.e., the
@@ -138,6 +146,10 @@ async def distribute_power(self, request: Request) -> None:
138146
)
139147

140148
num_components = len(working_components)
149+
if num_components == 0:
150+
_logger.error("No PV inverters available for power distribution. Aborting.")
151+
return
152+
141153
for idx, inv_id in enumerate(working_components):
142154
# Request powers are negative for PV inverters. When remaining power is
143155
# greater than or equal to 0.0, we can stop allocating further, and set 0

0 commit comments

Comments
 (0)