1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-25 22:52:20 +01:00

[mdns] Support templatable config options for MDNS extra services (#8606)

This commit is contained in:
Nate Clark
2025-04-28 00:27:39 -04:00
committed by GitHub
parent fdc4ec8a57
commit 253e3ec6f6
9 changed files with 45 additions and 21 deletions

View File

@@ -31,11 +31,12 @@ void MDNSComponent::setup() {
mdns_txt_item_t it{};
// dup strings to ensure the pointer is valid even after the record loop
it.key = strdup(record.key.c_str());
it.value = strdup(record.value.c_str());
it.value = strdup(const_cast<TemplatableValue<std::string> &>(record.value).value().c_str());
txt_records.push_back(it);
}
err = mdns_service_add(nullptr, service.service_type.c_str(), service.proto.c_str(), service.port,
txt_records.data(), txt_records.size());
uint16_t port = const_cast<TemplatableValue<uint16_t> &>(service.port).value();
err = mdns_service_add(nullptr, service.service_type.c_str(), service.proto.c_str(), port, txt_records.data(),
txt_records.size());
// free records
for (const auto &it : txt_records) {