From b4b8b43bd77f414f4d0784277dcc6ddac950e2ed Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 1 Oct 2025 22:34:32 +0200 Subject: [PATCH] preen --- esphome/components/mdns/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index 8c3193430c..12ec7353b5 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -17,6 +17,9 @@ from esphome.coroutine import CoroPriority CODEOWNERS = ["@esphome/core"] DEPENDENCIES = ["network"] +# Components that create mDNS services at runtime +COMPONENTS_WITH_MDNS_SERVICES = ("api", "prometheus", "web_server") + mdns_ns = cg.esphome_ns.namespace("mdns") MDNSComponent = mdns_ns.class_("MDNSComponent", cg.Component) MDNSTXTRecord = mdns_ns.struct("MDNSTXTRecord") @@ -92,9 +95,8 @@ async def to_code(config): cg.add_define("USE_MDNS") # Calculate compile-time service count - # Each of these components may create a service at runtime service_count = sum( - 1 for key in ("api", "prometheus", "web_server") if key in CORE.config + 1 for key in COMPONENTS_WITH_MDNS_SERVICES if key in CORE.config ) + len(config[CONF_SERVICES]) if config[CONF_SERVICES]: