diff --git a/custom_components/tuya_local/config_flow.py b/custom_components/tuya_local/config_flow.py index e35e6e23fd..39a80124ef 100644 --- a/custom_components/tuya_local/config_flow.py +++ b/custom_components/tuya_local/config_flow.py @@ -290,11 +290,11 @@ async def async_step_search(self, user_input=None): except OSError: local_device = {"ip": None, "version": ""} - if local_device["ip"] is not None: + if local_device.get("ip"): _LOGGER.debug(f"Found: {local_device}") - self.__cloud_device["ip"] = local_device["ip"] - self.__cloud_device["version"] = local_device["version"] - self.__cloud_device["local_product_id"] = local_device["productKey"] + self.__cloud_device["ip"] = local_device.get("ip") + self.__cloud_device["version"] = local_device.get("version") + self.__cloud_device["local_product_id"] = local_device.get("productKey") else: _LOGGER.warning(f"Could not find device: {self.__cloud_device['id']}") return await self.async_step_local()