Skip to content

Commit b7a4430

Browse files
committed
Add a EVChargeData.is_ev_connected method
When the charger is not in an error state, this would return whether an EV is connected to the charger or not. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 1595a5f commit b7a4430

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,18 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> EVChargerData:
397397
)
398398
ev_charger_data._set_raw(raw=raw)
399399
return ev_charger_data
400+
401+
def is_ev_connected(self) -> bool:
402+
"""Check whether an EV is connected to the charger.
403+
404+
Returns:
405+
When the charger is not in an error state, whether an EV is connected to
406+
the charger.
407+
"""
408+
return self.component_state not in (
409+
EVChargerComponentState.AUTHORIZATION_REJECTED,
410+
EVChargerComponentState.ERROR,
411+
) and self.cable_state in (
412+
EVChargerCableState.EV_LOCKED,
413+
EVChargerCableState.EV_PLUGGED,
414+
)

0 commit comments

Comments
 (0)