1717from .sensor_options import DEFS , SOPT
1818from .timer_callback import Callback
1919
20- _LOGGER = logging .getLogger (__name__ )
20+ _LOG = logging .getLogger (__name__ )
2121
2222
2323@attrs .define (slots = True , kw_only = True )
@@ -76,25 +76,25 @@ async def read_sensors_retry(self, *, sensors: list[Sensor], msg: str = "") -> b
7676 await self .read_sensors (sensors = sensors , msg = msg )
7777 return True
7878 except asyncio .exceptions .CancelledError as err :
79- _LOGGER .error ("Timeout %s" , err )
79+ _LOG .error ("Timeout %s" , err )
8080 except Exception as err :
81- _LOGGER .error ("%s" , err )
81+ _LOG .error ("%s" , err )
8282 await asyncio .sleep (0.1 )
8383 if self .read_errors > 2 :
8484 break
8585
8686 if len (sensors ) == 1 :
8787 return False
8888
89- _LOGGER .warning ("Retrying individual sensors: %s" , [s .id for s in sensors ])
89+ _LOG .warning ("Retrying individual sensors: %s" , [s .id for s in sensors ])
9090 errs = []
9191 for sen in sensors :
9292 await asyncio .sleep (0.02 )
9393 if not await self .read_sensors_retry (sensors = [sen ], msg = sen .name ):
9494 errs .append (sen .name )
9595
9696 if errs :
97- _LOGGER .critical ("Could not read sensors: %s" , errs )
97+ _LOG .critical ("Could not read sensors: %s" , errs )
9898 return False
9999 return True
100100
@@ -111,7 +111,7 @@ async def publish_sensors(self, *, states: dict[ASensor, ValType]) -> None:
111111
112112 async def connect (self ) -> None :
113113 """Connect."""
114- _LOGGER .info ("Connecting to %s" , self .inv .port )
114+ _LOG .info ("Connecting to %s" , self .inv .port )
115115 try :
116116 await self .inv .connect ()
117117 except ConnectionError as exc :
@@ -120,7 +120,7 @@ async def connect(self) -> None:
120120 ) from exc
121121
122122 sensors = list (SOPT .startup )
123- _LOGGER .info ("Reading startup sensors %s" , ", " .join (s .name for s in sensors ))
123+ _LOG .info ("Reading startup sensors %s" , ", " .join (s .name for s in sensors ))
124124
125125 if not await self .read_sensors_retry (sensors = sensors ):
126126 raise ConnectionError (
@@ -135,17 +135,17 @@ async def connect(self) -> None:
135135 )
136136 self .log_bold (f"Inverter serial number '****{ actual_ser [- 4 :]} '" )
137137
138- _LOGGER .info (
138+ _LOG .info (
139139 "Device type: %s, using the %s sensor definitions" ,
140140 self .inv .state [DEFS .device_type ],
141141 OPT .sensor_definitions ,
142142 )
143143
144- _LOGGER .info ("Protocol version: %s" , self .inv .state [DEFS .protocol ])
144+ _LOG .info ("Protocol version: %s" , self .inv .state [DEFS .protocol ])
145145
146146 # Initial read for all sensors
147147 sensors = list (SOPT )
148- _LOGGER .info ("Reading all sensors %s" , ", " .join (s .name for s in sensors ))
148+ _LOG .info ("Reading all sensors %s" , ", " .join (s .name for s in sensors ))
149149 await self .read_sensors (sensors = sensors )
150150
151151 @property
@@ -158,9 +158,9 @@ def rated_power(self) -> float:
158158
159159 def log_bold (self , msg : str ) -> None :
160160 """Log a message."""
161- _LOGGER .info ("#" * 60 )
162- _LOGGER .info (f"{ msg :^60} " .rstrip ())
163- _LOGGER .info ("#" * 60 )
161+ _LOG .info ("#" * 60 )
162+ _LOG .info (f"{ msg :^60} " .rstrip ())
163+ _LOG .info ("#" * 60 )
164164
165165 def hass_create_discovery_info (self ) -> None :
166166 """Create discovery info for the inverter."""
@@ -191,7 +191,7 @@ def hass_create_discovery_info(self) -> None:
191191 s .entity = s .create_entity (self )
192192 self .mqtt_dev .components [s .opt .sensor .id ] = s .entity
193193 except Exception as err :
194- _LOGGER .error ("Could not create MQTT entity for %s: %s" , s , err )
194+ _LOG .error ("Could not create MQTT entity for %s: %s" , s , err )
195195
196196 if hasattr (s .opt .sensor , "rated_power" ):
197197 s .opt .sensor .rated_power = int (self .rated_power ) # type:ignore[]
0 commit comments