8000 feat: add some logging for the web api by Lash-L · Pull Request #377 · Python-roborock/python-roborock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add some logging for the web api #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion roborock/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ async def _get_base_url(self) -> str:
raise RoborockUrlException("get url by email returned None")
response_code = response.get("code")
if response_code != 200:
_LOGGER.info("Get base url failed for %s with the following context: %s", self._username, response)
if response_code == 2003:
raise RoborockInvalidEmail("Your email was incorrectly formatted.")
elif response_code == 1001:
raise RoborockMissingParameters(
"You are missing parameters for this request, are you sure you " "entered your username?"
"You are missing parameters for this request, are you sure you entered your username?"
)
elif response_code == 9002:
raise RoborockTooManyRequest("Please temporarily disable making requests and try again later.")
Expand Down Expand Up @@ -214,6 +215,7 @@ async def request_code(self) -> None:
raise RoborockException("Failed to get a response from send email code")
response_code = code_response.get("code")
if response_code != 200:
_LOGGER.info("Request code failed for %s with the following context: %s", self._username, code_response)
if response_code == 2008:
raise RoborockAccountDoesNotExist("Account does not exist - check your login and try again.")
elif response_code == 9002:
Expand Down Expand Up @@ -243,6 +245,7 @@ async def pass_login(self, password: str) -> UserData:
if login_response is None:
raise RoborockException("Login response is none")
if login_response.get("code") != 200:
_LOGGER.info("Login failed for %s with the following context: %s", self._username, login_response)
raise RoborockException(f"{login_response.get('msg')} - response code: {login_response.get('code')}")
user_data = login_response.get("data")
if not isinstance(user_data, dict):
Expand Down Expand Up @@ -282,6 +285,7 @@ async def code_login(self, code: int | str) -> UserData:
raise RoborockException("Login request response is None")
response_code = login_response.get("code")
if response_code != 200:
_LOGGER.info("Login failed for %s with the following context: %s", self._username, login_response)
if response_code == 2018:
raise RoborockInvalidCode("Invalid code - check your code and try again.")
if response_code == 3009:
Expand All @@ -308,6 +312,7 @@ async def _get_home_id(self, user_data: UserData):
if home_id_response is None:
raise RoborockException("home_id_response is None")
if home_id_response.get("code") != 200:
_LOGGER.info("Get Home Id failed with the following context: %s", home_id_response)
if home_id_response.get("code") == 2010:
raise RoborockInvalidCredentials(
f"Invalid credentials ({home_id_response.get('msg')}) - check your login and try again."
Expand Down
0