From de2838fa6683c09916c180d53cf8369f009d6c67 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 1 Oct 2025 22:35:33 +0200 Subject: [PATCH] preen --- esphome/components/mdns/__init__.py | 2 ++ esphome/components/mdns/mdns_component.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index 12ec7353b5..ce0241677d 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -18,6 +18,8 @@ CODEOWNERS = ["@esphome/core"] DEPENDENCIES = ["network"] # Components that create mDNS services at runtime +# IMPORTANT: If you add a new component here, you must also update the corresponding +# #ifdef blocks in mdns_component.cpp compile_records_() method COMPONENTS_WITH_MDNS_SERVICES = ("api", "prometheus", "web_server") mdns_ns = cg.esphome_ns.namespace("mdns") diff --git a/esphome/components/mdns/mdns_component.cpp b/esphome/components/mdns/mdns_component.cpp index 6dba821258..58952e94e9 100644 --- a/esphome/components/mdns/mdns_component.cpp +++ b/esphome/components/mdns/mdns_component.cpp @@ -75,6 +75,9 @@ void MDNSComponent::compile_records_() { this->hostname_ = App.get_name(); this->services_count_ = 0; + // IMPORTANT: The #ifdef blocks below must match COMPONENTS_WITH_MDNS_SERVICES + // in mdns/__init__.py. If you add a new service here, update both locations. + #ifdef USE_API if (api::global_api_server != nullptr) { auto &service = this->services_[this->services_count_++];