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) 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):