Skip to content

Commit bd8a9f0

Browse files
committed
Start EV charger manager only if there are EV chargers in the graph
The EV charger manager has its own task that tracks the status of the EV chargers and redistributes power to them as EVs are connected and disconnected. This approach is specific to the EV charger pool, because the status of the components is dynamic, unlike the BatteryPool and the PVPool. This task needs to run only in locations where there are EV chargers, because it expects that there be at least one EV charger in a location and runs into issues if that's not the case. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 7240eca commit bd8a9f0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def component_ids(self) -> collections.abc.Set[int]:
7777
@override
7878
async def start(self) -> None:
7979
"""Start the ev charger data manager."""
80-
self._task = asyncio.create_task(self._run_forever())
80+
# Need to start a task only if there are EV chargers in the component graph.
81+
if self._ev_charger_ids:
82+
self._task = asyncio.create_task(self._run_forever())
8183

8284
@override
8385
async def distribute_power(self, request: Request) -> None:
@@ -86,7 +88,8 @@ async def distribute_power(self, request: Request) -> None:
8688
Args:
8789
request: Request to get the distribution for.
8890
"""
89-
await self._target_power_tx.send(request)
91+
if self._ev_charger_ids:
92+
await self._target_power_tx.send(request)
9093

9194
@override
9295
async def stop(self) -> None:

0 commit comments

Comments
 (0)