@@ -234,6 +234,7 @@ async def _request_json(
234234 authenticated : bool = False ,
235235 ct_json : bool = False ,
236236 ct_form : bool = False ,
237+ allow_redirects : bool = True ,
237238 ) -> dict [str , Any ] | Any :
238239 """Make an authenticated API request and return JSON response."""
239240 # Pass the content type flags to the header builder
@@ -261,12 +262,13 @@ async def _request_json(
261262 json = json_data ,
262263 data = form_data ,
263264 headers = request_headers , # Pass the constructed headers
264- allow_redirects = False , # Handle redirects manually if needed
265+ allow_redirects = allow_redirects ,
265266 ) as response :
266267 _LOGGER .error ("TESTv6 - Response code: %s" , response .status )
267268
268269 # v6 responds with a 302 redirect and empty body
269270 if url != self ._login_urls ["v6_login" ]:
271+ _LOGGER .error ("TESTv6 - we are in v8, raising for status" )
270272 response .raise_for_status ()
271273
272274 response_text = await response .text ()
@@ -277,6 +279,10 @@ async def _request_json(
277279 self ._store_auth_data (response )
278280 self .connected = True
279281
282+ # V6 responsds with empty body on login, not JSON
283+ if url != self ._login_urls ["v6_login" ] and not response_text :
284+ return {}
285+
280286 return json .loads (response_text )
281287 except aiohttp .ClientResponseError as err :
282288 _LOGGER .error (
@@ -345,6 +351,7 @@ async def login(self) -> None:
345351 headers = login_headers ,
346352 form_data = v6_simple_multipart_form_data ,
347353 authenticated = True ,
354+ allow_redirects = False ,
348355 )
349356 except (AirOSUrlNotFoundError , AirOSConnectionSetupError ) as err :
350357 _LOGGER .error (
0 commit comments