diff --git a/esphome/zeroconf.py b/esphome/zeroconf.py index b235f06786..c6a143a42f 100644 --- a/esphome/zeroconf.py +++ b/esphome/zeroconf.py @@ -18,6 +18,8 @@ from esphome.storage_json import StorageJSON, ext_storage_path _LOGGER = logging.getLogger(__name__) +DEFAULT_TIMEOUT = 10.0 +DEFAULT_TIMEOUT_MS = DEFAULT_TIMEOUT * 1000 _BACKGROUND_TASKS: set[asyncio.Task] = set() @@ -107,7 +109,7 @@ class DashboardImportDiscovery: self, zeroconf: Zeroconf, info: AsyncServiceInfo, service_type: str, name: str ) -> None: """Process a service info.""" - if await info.async_request(zeroconf, timeout=3000): + if await info.async_request(zeroconf, timeout=DEFAULT_TIMEOUT_MS): self._process_service_info(name, info) def _process_service_info(self, name: str, info: ServiceInfo) -> None: @@ -164,7 +166,9 @@ class DashboardImportDiscovery: class EsphomeZeroconf(Zeroconf): - def resolve_host(self, host: str, timeout: float = 3.0) -> list[str] | None: + def resolve_host( + self, host: str, timeout: float = DEFAULT_TIMEOUT + ) -> list[str] | None: """Resolve a host name to an IP address.""" info = AddressResolver(f"{host.partition('.')[0]}.local.") if ( @@ -177,7 +181,7 @@ class EsphomeZeroconf(Zeroconf): class AsyncEsphomeZeroconf(AsyncZeroconf): async def async_resolve_host( - self, host: str, timeout: float = 3.0 + self, host: str, timeout: float = DEFAULT_TIMEOUT ) -> list[str] | None: """Resolve a host name to an IP address.""" info = AddressResolver(f"{host.partition('.')[0]}.local.")