-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Iterate possible iot domains on 3030 error #733
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
base: main
Are you sure you want to change the base?
Conversation
|
I'll have to figure out how to best test this against real data, so I'll leave it in draft mode for now as RFC. |
|
ok yea, testing failed. This call isn't hte one that fails. |
|
Hi @Ongy! Thanks for taking a stab at this! You should be able to test this using the aioresponses patches we do. Looks like your issue is with: country and country code are not set here yet. |
|
Yea, no. It's the entirely wrong point to do this.
So we'd have to build a list here, and then do this error handling and iteration at login time :/ |
|
Do you get the error at the point of requesting the code or at the point of submitting the code? |
|
Pretty sure it's in the request. My python is rusty, so I don't always see how things flow immediately |
|
Okay cool! Better case for us than if it were in the submit code. I think the best way to handle it to keep it easy on the caller(i.e. HA) is:
Basically make request_code_v4 be responsible for handling this edge case and resolving it automatically. |
|
do you squash commits on merge or should I clean up history a bit? |
|
sorry for the unformatted/unlinted state. I don't know how to run the tooling locally :/ |
|
Oh, also haven't tested this against a real environment. Only the automated test I added. If there's some easy way to test in real, please give a commandline :) |
This error is returned by Roborock's API when there is an account currently in deletion. This can happen e.g. if a user erronously creates their account in the wrong region and then deletes it so they can create a new one in the correct region.
5f399f8 to
22241fc
Compare
|
The two options are: |
|
ok, so the code works but the local rate limiter kills it because it tries to login too quickly. Would you prefer to place the loop/recursion in a place that only grabs the rate limit before its entered or rather to add the url into the key for the rate limit? |
|
thoughts @allenporter ? We definitely want to make sure we aren't spamming request_code I'm not sure if you can move the limiter somewhere that would be okay. so in my mind there are two options:
|
|
My suggestion would be to not try to fight against rate limiting. If it's being hit it probably means we should rethink our appraoch. Given that roborock asks the user for their country/region in the app setup, and it effectively creates these silos, i think it may be worth just asking the user for the region in the setup flow. Is that an option? |
Yeah I'm fine with this and it is probably the way forward, but it is not ideal. We should default to auto functionality (where this logic may still be helpful for one retry) But the regions are unfortunately not as clear as you would hope. Some random countries were in US and some were in EU region that you wouldn't expect for both. I was not aware of a list or anyway to determine what countries are in what regions easily. So users will likely get confused for what region they should select when there is no region that matches their country well. |
|
So there's one thing I don't quite understand. Why do we even get an exception instead of blocking for a second? From the docs in https://github.com/vutran1710/PyrateLimiter?tab=readme-ov-file#blocking-vs-non-blocking I'd assume that we should block here. |
|
Found it. the default allowed amount to wait is 50ms, so I upped it to 1s (and made sure to switch to the Should work for up to 3 attempts, then the code will hit the per-minute limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds functionality to handle error code 3030 from Roborock's API, which occurs when an account is currently in deletion. The implementation allows the client to iterate through possible IoT domains when this error is encountered, enabling users who have deleted accounts in one region to successfully authenticate in another region.
Changes:
- Modified
request_code_v4to detect 3030 errors and retry with the next available IoT domain - Converted login rate limiter from synchronous to asynchronous and added max_delay parameter
- Added
_base_urlsinstance variable to track available URLs for iteration - Added comprehensive test case
test_thirty_thirty_cyclingto verify the new behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| roborock/web_api.py | Implements 3030 error handling with domain iteration, converts rate limiter to async, adds _base_urls tracking |
| tests/test_web_api.py | Adds test for 3030 cycling behavior, minor comment formatting fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| client = RoborockApiClient("test@example.com") | ||
| await client.request_code_v4() | ||
|
|
||
| print(mock_rest.requests) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed before merging. This appears to be leftover from development/debugging.
| print(mock_rest.requests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep please remove this print!
This error is returned by Roborock's API when there is an account currently in deletion.
This can happen e.g. if a user erronously creates their account in the wrong region and then deletes it so they can create a new one in the correct region.