Skip to content

Commit bea9449

Browse files
Fix PV power distribution
To exclude PV inverters that didn't send any data. The power distributor crashes because it tried to get data from a component that didn't send any data since the application startup. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent 9c54f8d commit bea9449

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Bug Fixes
44

5-
- Fix getting reactive power from meters, inverters and EV chargers.
5+
- Fix PV power distribution excluding inverters that haven't sent any data since the application started.

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
@@ -113,11 +113,19 @@ async def distribute_power(self, request: Request) -> None:
113113
raise ValueError(
114114
"Cannot distribute power to PV inverters without any inverters"
115115
)
116-
working_components = list(
117-
self._component_pool_status_tracker.get_working_components(
118-
request.component_ids
119-
)
120-
)
116+
117+
working_components: list[int] = []
118+
for inv_id in self._component_pool_status_tracker.get_working_components(
119+
request.component_ids
120+
):
121+
if self._component_data_caches[inv_id].has_value():
122+
working_components.append(inv_id)
123+
else:
124+
_logger.warning(
125+
"Exclude inverter %s from distribution, because it didn't "
126+
"send any data since the application startup.",
127+
inv_id,
128+
)
121129

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

132140
num_components = len(working_components)
141+
if num_components == 0:
142+
_logger.error("No inverters available for power distribution. Aborting.")
143+
return
144+
133145
for idx, inv_id in enumerate(working_components):
134146
# Request powers are negative for PV inverters. When remaining power is
135147
# greater than 0.0, we can stop allocating further.

0 commit comments

Comments
 (0)