Skip to content

Commit 703f48b

Browse files
authored
fix: add error code for invalid credentials (#101)
1 parent 2ea25d3 commit 703f48b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

roborock/api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
RoborockAccountDoesNotExist,
4747
RoborockException,
4848
RoborockInvalidCode,
49+
RoborockInvalidCredentials,
4950
RoborockInvalidEmail,
5051
RoborockInvalidUserAgreement,
5152
RoborockNoUserAgreement,
@@ -642,6 +643,10 @@ async def get_home_data(self, user_data: UserData) -> HomeData:
642643
if home_id_response is None:
643644
raise RoborockException("home_id_response is None")
644645
if home_id_response.get("code") != 200:
646+
if home_id_response.get("code") == 2010:
647+
raise RoborockInvalidCredentials(
648+
f"Invalid credentials ({home_id_response.get('msg')}) - check your login and try again."
649+
)
645650
raise RoborockException(f"{home_id_response.get('msg')} - response code: {home_id_response.get('code')}")
646651

647652
home_id = home_id_response["data"].get("rrHomeId")

roborock/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ class RoborockInvalidUserAgreement(RoborockException):
5656

5757
class RoborockNoUserAgreement(RoborockException):
5858
"""Class for Roborock no user agreement exceptions."""
59+
60+
61+
class RoborockInvalidCredentials(RoborockException):
62+
"""Class for Roborock credentials have expired or changed."""

0 commit comments

Comments
 (0)