@@ -28,6 +28,8 @@ class EVChargerState(Enum):
2828 """State of individual ev charger."""
2929
3030 UNSPECIFIED = "UNSPECIFIED"
31+ MISSING = "MISSING"
32+
3133 IDLE = "IDLE"
3234 EV_PLUGGED = "EV_PLUGGED"
3335 EV_LOCKED = "EV_LOCKED"
@@ -43,11 +45,16 @@ def from_ev_charger_data(cls, data: EVChargerData) -> EVChargerState:
4345 Returns:
4446 An `EVChargerState` instance.
4547 """
48+ if data .component_state == EVChargerComponentState .UNSPECIFIED :
49+ return EVChargerState .UNSPECIFIED
4650 if data .component_state in (
4751 EVChargerComponentState .AUTHORIZATION_REJECTED ,
4852 EVChargerComponentState .ERROR ,
4953 ):
5054 return EVChargerState .ERROR
55+
56+ if data .cable_state == EVChargerCableState .UNSPECIFIED :
57+ return EVChargerState .UNSPECIFIED
5158 if data .cable_state == EVChargerCableState .EV_LOCKED :
5259 return EVChargerState .EV_LOCKED
5360 if data .cable_state == EVChargerCableState .EV_PLUGGED :
@@ -145,12 +152,10 @@ async def _run(self) -> None:
145152 * [api_client .ev_charger_data (cid ) for cid in self ._component_ids ]
146153 )
147154
148- latest_messages : list [EVChargerData ] = await asyncio .gather (
149- * [stream .receive () for stream in streams ]
150- )
155+ # Start with the `MISSING` state for all components. This will change as data
156+ # starts arriving from the individual components.
151157 self ._states = {
152- msg .component_id : EVChargerState .from_ev_charger_data (msg )
153- for msg in latest_messages
158+ component_id : EVChargerState .MISSING for component_id in self ._component_ids
154159 }
155160 self ._merged_stream = Merge (* streams )
156161 sender = self ._channel .new_sender ()
0 commit comments