From 8902745a73bde6d56a76695fdccd51c1f9938d60 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Sun, 26 May 2024 22:37:37 +0900 Subject: [PATCH] Config flow: catch network errors when scanning Allow the config to proceed even when local network scan throws an error. Issue #1951 --- custom_components/tuya_local/config_flow.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_components/tuya_local/config_flow.py b/custom_components/tuya_local/config_flow.py index 847609a450..9f046d7846 100644 --- a/custom_components/tuya_local/config_flow.py +++ b/custom_components/tuya_local/config_flow.py @@ -372,9 +372,13 @@ async def async_step_search(self, user_input=None): f"Scanning network to get IP address for {self.__cloud_device['id']}." ) self.__cloud_device["ip"] = "" - local_device = await self.hass.async_add_executor_job( - scan_for_device, self.__cloud_device["id"] - ) + try: + local_device = await self.hass.async_add_executor_job( + scan_for_device, self.__cloud_device["id"] + ) + except OSError: + local_device = {"ip": None, "version": ""} + if local_device["ip"] is not None: _LOGGER.debug(f"Found: {local_device}") self.__cloud_device["ip"] = local_device["ip"]