Skip to content

Commit 2c7a705

Browse files
committed
Fix EVCharger status identification function
Earlier it was not consider all possible operational states. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 0143fbd commit 2c7a705

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/frequenz/sdk/actor/power_distributing/_component_status/_ev_charger_status_tracker.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@ def start(self) -> None:
7575
self._tasks.add(asyncio.create_task(self._run()))
7676

7777
def _is_working(self, ev_data: EVChargerData) -> bool:
78-
"""Return whether the given data indicates that the component is working."""
79-
return (
80-
ev_data.cable_state == EVChargerCableState.EV_PLUGGED
81-
and ev_data.component_state
82-
in (
83-
EVChargerComponentState.READY,
84-
EVChargerComponentState.CHARGING,
85-
)
78+
"""Return whether the given EV charger can be assigned power.
79+
80+
This is True when an EV is connected and the charger is in a healthy state.
81+
"""
82+
return ev_data.cable_state in (
83+
EVChargerCableState.EV_PLUGGED,
84+
EVChargerCableState.EV_LOCKED,
85+
) and ev_data.component_state in (
86+
EVChargerComponentState.READY,
87+
EVChargerComponentState.CHARGING,
88+
EVChargerComponentState.DISCHARGING,
8689
)
8790

8891
def _is_stale(self, ev_data: EVChargerData) -> bool:

src/frequenz/sdk/microgrid/component/_component_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ def is_ev_connected(self) -> bool:
478478
When the charger is not in an error state, whether an EV is connected to
479479
the charger.
480480
"""
481-
return self.component_state not in (
482-
EVChargerComponentState.AUTHORIZATION_REJECTED,
483-
EVChargerComponentState.ERROR,
481+
return self.component_state in (
482+
EVChargerComponentState.READY,
483+
EVChargerComponentState.CHARGING,
484+
EVChargerComponentState.DISCHARGING,
484485
) and self.cable_state in (
485486
EVChargerCableState.EV_LOCKED,
486487
EVChargerCableState.EV_PLUGGED,

0 commit comments

Comments
 (0)