3030_logger = logging .getLogger (__name__ )
3131
3232
33- class BatteryStatus (Enum ):
33+ class Status (Enum ):
3434 """Tells if battery is can be used."""
3535
3636 NOT_WORKING = 0
@@ -155,7 +155,7 @@ def __init__( # pylint: disable=too-many-arguments
155155 battery_id : int ,
156156 max_data_age_sec : float ,
157157 max_blocking_duration_sec : float ,
158- status_sender : Sender [BatteryStatus ],
158+ status_sender : Sender [Status ],
159159 request_result_receiver : Receiver [SetPowerResult ],
160160 ) -> None :
161161 """Create class instance.
@@ -178,7 +178,7 @@ def __init__( # pylint: disable=too-many-arguments
178178 self ._max_data_age = max_data_age_sec
179179 # First battery is considered as not working.
180180 # Change status after first messages are received.
181- self ._last_status = BatteryStatus .NOT_WORKING
181+ self ._last_status = Status .NOT_WORKING
182182 self ._blocking_status = _BlockingStatus (1.0 , max_blocking_duration_sec )
183183
184184 inverter_id = self ._find_adjacent_inverter_id (battery_id )
@@ -213,7 +213,7 @@ async def stop(self) -> None:
213213
214214 async def _run (
215215 self ,
216- status_sender : Sender [BatteryStatus ],
216+ status_sender : Sender [Status ],
217217 request_result_receiver : Receiver [SetPowerResult ],
218218 ) -> None :
219219 """Process data from the components and request_result_receiver.
@@ -247,7 +247,7 @@ async def _run(
247247 except Exception as err : # pylint: disable=broad-except
248248 _logger .exception ("BatteryStatusTracker crashed with error: %s" , err )
249249
250- def _update_status (self , select : Select ) -> Optional [BatteryStatus ]:
250+ def _update_status (self , select : Select ) -> Optional [Status ]:
251251 if msg := select .battery :
252252 self ._battery .last_msg_correct = (
253253 self ._is_message_reliable (msg .inner )
@@ -309,7 +309,7 @@ def _update_status(self, select: Select) -> Optional[BatteryStatus]:
309309
310310 return None
311311
312- def _get_current_status (self ) -> BatteryStatus :
312+ def _get_current_status (self ) -> Status :
313313 """Get current battery status.
314314
315315 Returns:
@@ -320,15 +320,15 @@ def _get_current_status(self) -> BatteryStatus:
320320 )
321321
322322 if not is_msg_correct :
323- return BatteryStatus .NOT_WORKING
324- if self ._last_status == BatteryStatus .NOT_WORKING :
323+ return Status .NOT_WORKING
324+ if self ._last_status == Status .NOT_WORKING :
325325 # If message just become correct, then try to use it
326326 self ._blocking_status .unblock ()
327- return BatteryStatus .WORKING
327+ return Status .WORKING
328328 if self ._blocking_status .is_blocked ():
329- return BatteryStatus .UNCERTAIN
329+ return Status .UNCERTAIN
330330
331- return BatteryStatus .WORKING
331+ return Status .WORKING
332332
333333 def _no_critical_error (self , msg : Union [BatteryData , InverterData ]) -> bool :
334334 """Check if battery or inverter message has any critical error.
@@ -343,7 +343,7 @@ def _no_critical_error(self, msg: Union[BatteryData, InverterData]) -> bool:
343343 # pylint: disable=protected-access
344344 critical_err = next ((err for err in msg ._errors if err .level == critical ), None )
345345 if critical_err is not None :
346- if self ._last_status == BatteryStatus .WORKING :
346+ if self ._last_status == Status .WORKING :
347347 _logger .warning (
348348 "Component %d has critical error: %s" ,
349349 msg .component_id ,
@@ -365,7 +365,7 @@ def _is_inverter_state_correct(self, msg: InverterData) -> bool:
365365 # pylint: disable=protected-access
366366 state = msg ._component_state
367367 if state not in BatteryStatusTracker ._inverter_valid_state :
368- if self ._last_status == BatteryStatus .WORKING :
368+ if self ._last_status == Status .WORKING :
369369 _logger .warning (
370370 "Inverter %d has invalid state: %s" ,
371371 msg .component_id ,
@@ -387,7 +387,7 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
387387 # pylint: disable=protected-access
388388 state = msg ._component_state
389389 if state not in BatteryStatusTracker ._battery_valid_state :
390- if self ._last_status == BatteryStatus .WORKING :
390+ if self ._last_status == Status .WORKING :
391391 _logger .warning (
392392 "Battery %d has invalid state: %s" ,
393393 self .battery_id ,
@@ -399,7 +399,7 @@ def _is_battery_state_correct(self, msg: BatteryData) -> bool:
399399 # pylint: disable=protected-access
400400 relay_state = msg ._relay_state
401401 if relay_state not in BatteryStatusTracker ._battery_valid_relay :
402- if self ._last_status == BatteryStatus .WORKING :
402+ if self ._last_status == Status .WORKING :
403403 _logger .warning (
404404 "Battery %d has invalid relay state: %s" ,
405405 self .battery_id ,
@@ -432,7 +432,7 @@ def _is_message_reliable(self, message: ComponentData) -> bool:
432432 """
433433 is_outdated = self ._is_timestamp_outdated (message .timestamp )
434434
435- if is_outdated and self ._last_status == BatteryStatus .WORKING :
435+ if is_outdated and self ._last_status == Status .WORKING :
436436 _logger .warning (
437437 "Component %d stopped sending data. Last timestamp: %s." ,
438438 message .component_id ,
0 commit comments