diff --git a/esphome/components/mdns/mdns_component.h b/esphome/components/mdns/mdns_component.h index 9193aaaf31..fdbe5b11e7 100644 --- a/esphome/components/mdns/mdns_component.h +++ b/esphome/components/mdns/mdns_component.h @@ -39,7 +39,7 @@ class MDNSComponent : public Component { float get_setup_priority() const override { return setup_priority::AFTER_CONNECTION; } #ifdef USE_MDNS_EXTRA_SERVICES - void add_extra_service(MDNSService service) { this->services_.push_back(std::move(service)); } + void add_extra_service(MDNSService service) { this->services_[this->services_.count()++] = std::move(service); } #endif const StaticVector &get_services() const { return this->services_; }