@@ -73,6 +73,7 @@ def __post_init__(self) -> None:
7373 f"than maximum blocking duration ({ self .max_duration } )"
7474 )
7575 self .last_blocking_duration = self .min_duration
76+ self ._timedelta_zero = timedelta (seconds = 0.0 )
7677
7778 def block (self ) -> timedelta :
7879 """Block battery.
@@ -92,7 +93,7 @@ def block(self) -> timedelta:
9293
9394 # If still blocked, then do nothing
9495 if self .blocked_until > now :
95- return timedelta ( seconds = 0.0 )
96+ return self . _timedelta_zero
9697
9798 # If previous blocking time expired, then blocked it once again.
9899 # Increase last blocking time, unless it reach the maximum.
@@ -192,6 +193,7 @@ def __init__( # pylint: disable=too-many-arguments
192193 self ._blocking_status : _BlockingStatus = _BlockingStatus (
193194 timedelta (seconds = 1.0 ), max_blocking_duration
194195 )
196+ self ._timedelta_zero = timedelta (seconds = 0.0 )
195197
196198 inverter_id = self ._find_adjacent_inverter_id (component_id )
197199 if inverter_id is None :
@@ -256,7 +258,7 @@ def _handle_status_set_power_result(self, result: SetPowerResult) -> None:
256258 ):
257259 duration = self ._blocking_status .block ()
258260
259- if duration > timedelta ( seconds = 0.0 ) :
261+ if duration > self . _timedelta_zero :
260262 _logger .warning (
261263 "battery %d failed last response. block it for %s" ,
262264 self .battery_id ,
0 commit comments