Skip to content

Commit 0374449

Browse files
authored
feat: add error check for invalid user agreement (#49)
* minor: add error check for invalid user agreement * fix: lint * feat: add no user agreement error * fix: version issue * fix: added account to str
1 parent 1555314 commit 0374449

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pycryptodome = "~3.17.0"
2727
pycryptodomex = {version = "~3.17.0", markers = "sys_platform == 'darwin'"}
2828
paho-mqtt = "~1.6.1"
2929
dacite = "~1.8.0"
30-
construct = "^2.10.68"
30+
construct = "^2.10.56"
3131

3232

3333
[build-system]

roborock/api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
RoborockException,
4040
RoborockInvalidCode,
4141
RoborockInvalidEmail,
42+
RoborockInvalidUserAgreement,
43+
RoborockNoUserAgreement,
4244
RoborockTimeout,
4345
RoborockUrlException,
4446
VacuumError,
@@ -474,6 +476,12 @@ async def code_login(self, code) -> UserData:
474476
if response_code != 200:
475477
if response_code == 2018:
476478
raise RoborockInvalidCode("Invalid code - check your code and try again.")
479+
if response_code == 3009:
480+
raise RoborockNoUserAgreement("You must accept the user agreement in the Roborock app to continue.")
481+
if response_code == 3006:
482+
raise RoborockInvalidUserAgreement(
483+
"User agreement must be accepted again - or you are attempting to use the Mi Home app account."
484+
)
477485
raise RoborockException(f"{login_response.get('msg')} - response code: {response_code}")
478486
user_data = login_response.get("data")
479487
if not isinstance(user_data, dict):

roborock/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ class RoborockInvalidCode(RoborockException):
5252

5353
class RoborockInvalidEmail(RoborockException):
5454
"""Class for Roborock invalid formatted email exceptions."""
55+
56+
57+
class RoborockInvalidUserAgreement(RoborockException):
58+
"""Class for Roborock invalid user agreement exceptions."""
59+
60+
61+
class RoborockNoUserAgreement(RoborockException):
62+
"""Class for Roborock no user agreement exceptions."""

0 commit comments

Comments
 (0)