Increase zeroconf timeout to 10 seconds (#8670)

This commit is contained in:
J. Nick Koston 2025-05-08 19:05:59 -05:00 committed by GitHub
parent b01d85a974
commit 782d748210
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.")