1818 KeyDataMissingError ,
1919)
2020
21- logger = logging .getLogger (__name__ )
21+ _LOGGER = logging .getLogger (__name__ )
2222
2323
2424class AirOS :
@@ -101,10 +101,10 @@ async def login(self) -> bool:
101101 headers = login_request_headers ,
102102 ) as response :
103103 if response .status == 403 :
104- logger .error ("Authentication denied." )
104+ _LOGGER .error ("Authentication denied." )
105105 raise ConnectionAuthenticationError from None
106106 if not response .cookies :
107- logger .exception ("Empty cookies after login, bailing out." )
107+ _LOGGER .exception ("Empty cookies after login, bailing out." )
108108 raise ConnectionSetupError from None
109109 else :
110110 for _ , morsel in response .cookies .items ():
@@ -155,7 +155,7 @@ async def login(self) -> bool:
155155 airos_cookie_found = False
156156 ok_cookie_found = False
157157 if not self .session .cookie_jar : # pragma: no cover
158- logger .exception (
158+ _LOGGER .exception (
159159 "COOKIE JAR IS EMPTY after login POST. This is a major issue."
160160 )
161161 raise ConnectionSetupError from None
@@ -176,24 +176,24 @@ async def login(self) -> bool:
176176 self .connected = True
177177 return True
178178 except json .JSONDecodeError as err :
179- logger .exception ("JSON Decode Error" )
179+ _LOGGER .exception ("JSON Decode Error" )
180180 raise DataMissingError from err
181181
182182 else :
183183 log = f"Login failed with status { response .status } . Full Response: { response .text } "
184- logger .error (log )
184+ _LOGGER .error (log )
185185 raise ConnectionAuthenticationError from None
186186 except (
187187 aiohttp .ClientError ,
188188 aiohttp .client_exceptions .ConnectionTimeoutError ,
189189 ) as err :
190- logger .exception ("Error during login" )
190+ _LOGGER .exception ("Error during login" )
191191 raise DeviceConnectionError from err
192192
193193 async def status (self ) -> AirOSData :
194194 """Retrieve status from the device."""
195195 if not self .connected :
196- logger .error ("Not connected, login first" )
196+ _LOGGER .error ("Not connected, login first" )
197197 raise DeviceConnectionError from None
198198
199199 # --- Step 2: Verify authenticated access by fetching status.cgi ---
@@ -213,32 +213,32 @@ async def status(self) -> AirOSData:
213213 try :
214214 airos_data = AirOSData .from_dict (response_json )
215215 except (MissingField , InvalidFieldValue ) as err :
216- logger .exception ("Failed to deserialize AirOS data" )
216+ _LOGGER .exception ("Failed to deserialize AirOS data" )
217217 raise KeyDataMissingError from err
218218
219219 return airos_data
220220 except json .JSONDecodeError :
221- logger .exception (
221+ _LOGGER .exception (
222222 "JSON Decode Error in authenticated status response"
223223 )
224224 raise DataMissingError from None
225225 else :
226226 log = f"Authenticated status.cgi failed: { response .status } . Response: { response_text } "
227- logger .error (log )
227+ _LOGGER .error (log )
228228 except (
229229 aiohttp .ClientError ,
230230 aiohttp .client_exceptions .ConnectionTimeoutError ,
231231 ) as err :
232- logger .exception ("Error during authenticated status.cgi call" )
232+ _LOGGER .exception ("Error during authenticated status.cgi call" )
233233 raise DeviceConnectionError from err
234234
235235 async def stakick (self , mac_address : str = None ) -> bool :
236236 """Reconnect client station."""
237237 if not self .connected :
238- logger .error ("Not connected, login first" )
238+ _LOGGER .error ("Not connected, login first" )
239239 raise DeviceConnectionError from None
240240 if not mac_address :
241- logger .error ("Device mac-address missing" )
241+ _LOGGER .error ("Device mac-address missing" )
242242 raise DataMissingError from None
243243
244244 kick_request_headers = {** self ._common_headers }
@@ -262,11 +262,11 @@ async def stakick(self, mac_address: str = None) -> bool:
262262 return True
263263 response_text = await response .text ()
264264 log = f"Unable to restart connection response status { response .status } with { response_text } "
265- logger .error (log )
265+ _LOGGER .error (log )
266266 return False
267267 except (
268268 aiohttp .ClientError ,
269269 aiohttp .client_exceptions .ConnectionTimeoutError ,
270270 ) as err :
271- logger .exception ("Error during reconnect stakick.cgi call" )
271+ _LOGGER .exception ("Error during reconnect stakick.cgi call" )
272272 raise DeviceConnectionError from err
0 commit comments