From 047c18eac0ca65a6609c58d4fd419e389968031f Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 14 Apr 2022 11:25:31 +1200 Subject: [PATCH] Add default object_id_generator for mqtt (#3389) --- esphome/components/mqtt/mqtt_client.cpp | 7 ++++++- esphome/components/mqtt/mqtt_client.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/esphome/components/mqtt/mqtt_client.cpp b/esphome/components/mqtt/mqtt_client.cpp index 3c6ce7cdfc..12a43dc232 100644 --- a/esphome/components/mqtt/mqtt_client.cpp +++ b/esphome/components/mqtt/mqtt_client.cpp @@ -556,7 +556,12 @@ void MQTTClientComponent::disable_last_will() { this->last_will_.topic = ""; } void MQTTClientComponent::disable_discovery() { this->discovery_info_ = MQTTDiscoveryInfo{ - .prefix = "", .retain = false, .clean = false, .unique_id_generator = MQTT_LEGACY_UNIQUE_ID_GENERATOR}; + .prefix = "", + .retain = false, + .clean = false, + .unique_id_generator = MQTT_LEGACY_UNIQUE_ID_GENERATOR, + .object_id_generator = MQTT_NONE_OBJECT_ID_GENERATOR, + }; } void MQTTClientComponent::on_shutdown() { if (!this->shutdown_message_.topic.empty()) { diff --git a/esphome/components/mqtt/mqtt_client.h b/esphome/components/mqtt/mqtt_client.h index 4880bbaa5b..20b174a66f 100644 --- a/esphome/components/mqtt/mqtt_client.h +++ b/esphome/components/mqtt/mqtt_client.h @@ -277,6 +277,7 @@ class MQTTClientComponent : public Component { .retain = true, .clean = false, .unique_id_generator = MQTT_LEGACY_UNIQUE_ID_GENERATOR, + .object_id_generator = MQTT_NONE_OBJECT_ID_GENERATOR, }; std::string topic_prefix_{}; MQTTMessage log_message_;