From 9f6e6b2925cbd8433badb74b118520cc438f20a5 Mon Sep 17 00:00:00 2001 From: Hadrien Beaufils Date: Sun, 20 Jul 2025 10:03:40 +0200 Subject: [PATCH 1/2] Fix homes retrieval when there's no 'share_home_list'. --- .../common/xiaomi_cloud_connector.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/xiaomi_cloud_map_extractor/common/xiaomi_cloud_connector.py b/custom_components/xiaomi_cloud_map_extractor/common/xiaomi_cloud_connector.py index 60f0cfd..24a83d9 100644 --- a/custom_components/xiaomi_cloud_map_extractor/common/xiaomi_cloud_connector.py +++ b/custom_components/xiaomi_cloud_map_extractor/common/xiaomi_cloud_connector.py @@ -163,10 +163,12 @@ def get_homes_iter(self, country: str): if (response := self.execute_api_call_encrypted(url, params)) is None: return None - if homelist := response["result"]["homelist"]: + result = response["result"] + + if homelist := result["homelist"]: yield from (XiaomiHome(int(home["id"]), home["uid"]) for home in homelist) - if homelist := response["result"]["share_home_list"]: + if homelist := result.get("share_home_list", None): yield from (XiaomiHome(int(home["id"]), home["uid"]) for home in homelist) def get_devices_from_home_iter(self, country: str, home_id: int, owner_id: int): From c32ace83f6fdc137f5a347da564d77f7927636be Mon Sep 17 00:00:00 2001 From: Hadrien Beaufils Date: Sun, 20 Jul 2025 10:06:03 +0200 Subject: [PATCH 2/2] Add error log to indicate a failure to find the device specified in the configuration. --- custom_components/xiaomi_cloud_map_extractor/camera.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_cloud_map_extractor/camera.py b/custom_components/xiaomi_cloud_map_extractor/camera.py index d807cfc..79cb7f7 100644 --- a/custom_components/xiaomi_cloud_map_extractor/camera.py +++ b/custom_components/xiaomi_cloud_map_extractor/camera.py @@ -312,7 +312,12 @@ def _handle_login(self): def _handle_device(self): _LOGGER.debug("Retrieving device info, country: %s", self._country) - country, user_id, device_id, model = self._connector.get_device_details(self._vacuum.token, self._country) + token = self._vacuum.token + country, user_id, device_id, model = self._connector.get_device_details(token, self._country) + + if device_id is None: + _LOGGER.error("Failed to find a device matching the given token: %s", token) + if model is not None: self._country = country _LOGGER.debug("Retrieved device model: %s", model)