Skip to content

Commit

Permalink
Config flow: catch network errors when scanning
Browse files Browse the repository at this point in the history
Allow the config to proceed even when local network scan throws an error.

Issue make-all#1951
  • Loading branch information
make-all authored and timlaing committed Aug 8, 2024
1 parent 0ef1dbd commit deab8e5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/tuya_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit deab8e5

Please sign in to comment.