From 0d94ffe15dbde9cd0bb8f852b7167e14417bdbda Mon Sep 17 00:00:00 2001 From: dbl-0 Date: Wed, 6 May 2026 11:48:38 -0600 Subject: [PATCH] [resolver] Make RESOLVE_TIMEOUT configurable via environment variable (#15951) Co-authored-by: Daniel Lowe Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> --- esphome/resolver.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/esphome/resolver.py b/esphome/resolver.py index 9fb596ce7b..f80a910afe 100644 --- a/esphome/resolver.py +++ b/esphome/resolver.py @@ -2,13 +2,28 @@ from __future__ import annotations +import logging +import os + from aioesphomeapi.core import ResolveAPIError, ResolveTimeoutAPIError import aioesphomeapi.host_resolver as hr from esphome.async_thread import AsyncThreadRunner from esphome.core import EsphomeError -RESOLVE_TIMEOUT = 10.0 # seconds +_LOGGER = logging.getLogger(__name__) + +_DEFAULT_RESOLVE_TIMEOUT = 20.0 +_env_timeout = os.environ.get("ESPHOME_RESOLVE_TIMEOUT", _DEFAULT_RESOLVE_TIMEOUT) +try: + RESOLVE_TIMEOUT = float(_env_timeout) +except ValueError: + _LOGGER.warning( + "ESPHOME_RESOLVE_TIMEOUT=%r is not a valid number; using default %.1fs", + _env_timeout, + _DEFAULT_RESOLVE_TIMEOUT, + ) + RESOLVE_TIMEOUT = _DEFAULT_RESOLVE_TIMEOUT class AsyncResolver: