Skip to content

Commit 5100594

Browse files
authored
Allow create PVPool instances in locations without PV (#1215)
Closes #1130
2 parents a582535 + 5f4d157 commit 5100594

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@
5353
| Battery | 0.0 |
5454
| PV | Minimum power (aka max production power) |
5555
| EV Chargers | Maximum power (aka max consumption power) |
56+
57+
- PV Pool instances can now be created in sites without any PV. This allows for writing generic code that works for all locations, that depends on the PV power formula, for example.

src/frequenz/sdk/timeseries/pv_pool/_pv_pool_reference_store.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,20 @@ def __init__( # pylint: disable=too-many-arguments
9797
name=f"System Bounds for PV inverters: {component_ids}",
9898
resend_latest=True,
9999
)
100-
self.bounds_tracker: PVSystemBoundsTracker = PVSystemBoundsTracker(
101-
self.component_ids,
102-
self.status_receiver,
103-
self.bounds_channel.new_sender(),
104-
)
105-
self.bounds_tracker.start()
100+
101+
self.bounds_tracker: PVSystemBoundsTracker | None = None
102+
# In locations without PV inverters, the bounds tracker will not be started.
103+
if self.component_ids:
104+
self.bounds_tracker = PVSystemBoundsTracker(
105+
self.component_ids,
106+
self.status_receiver,
107+
self.bounds_channel.new_sender(),
108+
)
109+
self.bounds_tracker.start()
106110

107111
async def stop(self) -> None:
108112
"""Stop all tasks and channels owned by the PVInverterPool."""
109113
await self.formula_pool.stop()
110-
await self.bounds_tracker.stop()
114+
if self.bounds_tracker is not None:
115+
await self.bounds_tracker.stop()
111116
self.status_receiver.close()

0 commit comments

Comments
 (0)