@@ -98,7 +98,7 @@ async def _get_iot_login_info(self) -> IotLoginInfo:
9898 raise RoborockException (f"{ response .get ('msg' )} - response code: { response_code } " )
9999 country_code = response ["data" ]["countrycode" ]
100100 country = response ["data" ]["country" ]
101- if country_code is not None and country is not None :
101+ if country_code is not None or country is not None :
102102 self ._iot_login_info = IotLoginInfo (
103103 base_url = response ["data" ]["url" ],
104104 country = country ,
@@ -234,6 +234,9 @@ async def request_code(self) -> None:
234234
235235 async def request_code_v4 (self ) -> None :
236236 """Request a code using the v4 endpoint."""
237+ if await self .country_code is None or await self .country is None :
238+ _LOGGER .info ("No country code or country found, trying old version of request code." )
239+ return await self .request_code ()
237240 try :
238241 self ._login_limiter .try_acquire ("login" )
239242 except BucketFullException as ex :
@@ -304,6 +307,9 @@ async def code_login_v4(
304307 country = await self .country
305308 if country_code is None :
306309 country_code = await self .country_code
310+ if country_code is None or country is None :
311+ _LOGGER .info ("No country code or country found, trying old version of code login." )
312+ return await self .code_login (code )
307313 header_clientid = self ._get_header_client_id ()
308314 x_mercy_ks = "" .join (secrets .choice (string .ascii_letters + string .digits ) for _ in range (16 ))
309315 x_mercy_k = await self ._sign_key_v3 (x_mercy_ks )
0 commit comments