feat: add support for extracting cloud keys via quick login#291
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #291 +/- ##
==========================================
- Coverage 54.28% 52.93% -1.35%
==========================================
Files 7 7
Lines 1378 1464 +86
Branches 268 281 +13
==========================================
+ Hits 748 775 +27
- Misses 512 573 +61
+ Partials 118 116 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for this PR. Can you please have a look at the failing checks first? |
|
@bluetoothbot review |
To help move this forward, here's why the checks are red:
|
PR Review — feat: add support for extracting cloud keys via quick loginThe refactor to split 🔴 Blocking1. QR long-poll has dead timeout guard and no polling loop (`src/xiaomi_ble/cloud.py`, L418-424)
Suggested shape: async def _login_step_2(self) -> bool:
deadline = time.time() + self._timeout / 1000
while time.time() < deadline:
response = await self._session.get(self._long_polling_url)
if response.status != 200:
return False
data = self.to_json(await response.text())
if "ssecurity" in data:
self.userId = data["userId"]
self._ssecurity = data["ssecurity"]
...
return True
return False2. Untyped __init__ and attributes will fail the strict mypy lint check (`src/xiaomi_ble/cloud.py`, L386-393)This is almost certainly the source of the failing CI
Annotate explicitly, mirroring the password connector: 🟡 Important1. _timeout never initialized; step_1 success path doesn't require a QR (`src/xiaomi_ble/cloud.py`, L409-416)
Validate the body and fail loudly: if valid:
response_data = self.to_json(await response.text())
if "qr" not in response_data:
return False
self._qr_image_url = response_data["qr"]
...and initialize 2. New auth flow is entirely untested (patch coverage 18%) (`src/xiaomi_ble/cloud.py`, L294-462)Codecov reports 106 of the new lines uncovered and overall coverage dropping 1.49%. There is currently no test module for Please add tests that mock 3. session made optional but is dereferenced unconditionally (`src/xiaomi_ble/cloud.py`, L367-375)
Keep 🟢 Suggestions1. serviceToken cookie may be absent; .value will raise (`src/xiaomi_ble/cloud.py`, L435-446)
token = response.cookies.get("serviceToken")
if token is None:
return False
self._serviceToken = token.value2. Naming inconsistency and unused attributes between connectors (`src/xiaomi_ble/cloud.py`, L388-392)The QR connector stores Checklist
SummaryThe refactor to split To rebase specific severity levels, mention me: Automated review by Kōan82c1586 |
Password login often requires a verification code, so I added another login method.
This is a change to the core integration. lzghzr/ha-core@5b17bb2
2026-04-14.21.35.49.mov