Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 9 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the V4 code login implementation to properly align with the Roborock app's authentication flow. The changes ensure the API requests match the expected format by switching from query parameters to form-encoded request body data and adding required headers.
- Switched from
paramstodatain bothrequest_code_v4()andcode_login_v4()functions to properly send data as form-encoded in the request body - Added additional required headers for V4 login including app version, phone system, phone model, and language settings
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Content-Type": "application/x-www-form-urlencoded", | ||
| "header_clientlang": "en", | ||
| "header_appversion": "4.54.02", | ||
| "header_phonesystem": "iOS", | ||
| "header_phonemodel": "iPhone16,1", | ||
| }, |
There was a problem hiding this comment.
Consider adding a comment explaining why these specific header values (Content-Type, language "en", phone system "iOS", phone model "iPhone16,1") are required for the V4 API. This would help future maintainers understand if these values need to be adjusted or made configurable.
| "x-mercy-k": x_mercy_k, | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| "header_clientlang": "en", | ||
| "header_appversion": "4.54.02", |
There was a problem hiding this comment.
The hardcoded app version "4.54.02" may become outdated as the Roborock app is updated. Consider adding a comment explaining why this specific version is used, or if possible, making it configurable to ensure future compatibility with the API.
The fix is the extra headers, it does not seem like any can be removed.
The api also accepts params or data, but data better aligns to the app, so we are switching to that.
home-assistant/core#158306