Skip to content

Commit 9484f6a

Browse files
committed
fix: address comments
1 parent 01d1fdc commit 9484f6a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

roborock/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class RRiot(RoborockBase):
226226

227227
@dataclass
228228
class UserData(RoborockBase):
229+
rriot: RRiot
229230
uid: int | None = None
230231
tokentype: str | None = None
231232
token: str | None = None
@@ -234,7 +235,6 @@ class UserData(RoborockBase):
234235
countrycode: str | None = None
235236
country: str | None = None
236237
nickname: str | None = None
237-
rriot: RRiot | None = None
238238
tuya_device_state: int | None = None
239239
avatarurl: str | None = None
240240

roborock/web_api.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async def _get_home_id(self, user_data: UserData):
285285
)
286286
raise RoborockException(f"{home_id_response.get('msg')} - response code: {home_id_response.get('code')}")
287287

288-
return home_id_response["data"].get("rrHomeId")
288+
return home_id_response["data"]["rrHomeId"]
289289

290290
async def get_home_data(self, user_data: UserData) -> HomeData:
291291
rriot = user_data.rriot
@@ -335,25 +335,22 @@ async def get_home_data_v2(self, user_data: UserData) -> HomeData:
335335
async def get_home_data_v3(self, user_data: UserData) -> HomeData:
336336
"""This is the same as get_home_data, but uses a different endpoint and includes non-robotic vacuums."""
337337
rriot = user_data.rriot
338-
if rriot is None:
339-
raise RoborockException("rriot is none")
340338
home_id = await self._get_home_id(user_data)
341339
if rriot.r.a is None:
342340
raise RoborockException("Missing field 'a' in rriot reference")
343341
home_request = PreparedRequest(
344342
rriot.r.a,
345343
{
346-
"Authorization": self._get_hawk_authentication(rriot, "/v3/user/homes/" + str(home_id)),
344+
"Authorization": self._get_hawk_authentication(rriot, "/v3/user/homes/" + home_id),
347345
},
348346
)
349-
home_response = await home_request.request("get", "/v3/user/homes/" + str(home_id))
347+
home_response = await home_request.request("get", "/v3/user/homes/" + home_id)
350348
if not home_response.get("success"):
351349
raise RoborockException(home_response)
352350
home_data = home_response.get("result")
353351
if isinstance(home_data, dict):
354352
return HomeData.from_dict(home_data)
355-
else:
356-
raise RoborockException("home_response result was an unexpected type")
353+
raise RoborockException(f"home_response result was an unexpected type: {home_data}")
357354

358355
async def get_rooms(self, user_data: UserData, home_id: int | None = None) -> list[HomeDataRoom]:
359356
rriot = user_data.rriot

0 commit comments

Comments
 (0)