diff --git a/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.cpp b/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.cpp index a79216e04de..834b77f279d 100644 --- a/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.cpp +++ b/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.cpp @@ -27,7 +27,7 @@ void MQTTSubscribeSensor::setup() { float MQTTSubscribeSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; } void MQTTSubscribeSensor::dump_config() { LOG_SENSOR("", "MQTT Subscribe", this); - ESP_LOGCONFIG(TAG, " Topic: %s", this->topic_.c_str()); + ESP_LOGCONFIG(TAG, " Topic: %s", this->topic_); } } // namespace esphome::mqtt_subscribe diff --git a/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.h b/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.h index b0a8a0a78a2..1b1b460e4e9 100644 --- a/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.h +++ b/esphome/components/mqtt_subscribe/sensor/mqtt_subscribe_sensor.h @@ -13,7 +13,7 @@ namespace esphome::mqtt_subscribe { class MQTTSubscribeSensor final : public sensor::Sensor, public Component { public: void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; } - void set_topic(const std::string &topic) { topic_ = topic; } + void set_topic(const char *topic) { this->topic_ = topic; } void setup() override; void dump_config() override; float get_setup_priority() const override; @@ -22,7 +22,7 @@ class MQTTSubscribeSensor final : public sensor::Sensor, public Component { protected: mqtt::MQTTClientComponent *parent_; - std::string topic_; + const char *topic_{nullptr}; uint8_t qos_{0}; }; diff --git a/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.cpp b/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.cpp index 55992f42f99..0748eac3923 100644 --- a/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.cpp +++ b/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.cpp @@ -17,7 +17,7 @@ void MQTTSubscribeTextSensor::setup() { float MQTTSubscribeTextSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; } void MQTTSubscribeTextSensor::dump_config() { LOG_TEXT_SENSOR("", "MQTT Subscribe Text Sensor", this); - ESP_LOGCONFIG(TAG, " Topic: %s", this->topic_.c_str()); + ESP_LOGCONFIG(TAG, " Topic: %s", this->topic_); } } // namespace esphome::mqtt_subscribe diff --git a/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.h b/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.h index dc02eb5d187..7c68aab7e60 100644 --- a/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.h +++ b/esphome/components/mqtt_subscribe/text_sensor/mqtt_subscribe_text_sensor.h @@ -13,7 +13,7 @@ namespace esphome::mqtt_subscribe { class MQTTSubscribeTextSensor final : public text_sensor::TextSensor, public Component { public: void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; } - void set_topic(const std::string &topic) { topic_ = topic; } + void set_topic(const char *topic) { this->topic_ = topic; } void setup() override; void dump_config() override; float get_setup_priority() const override; @@ -21,7 +21,7 @@ class MQTTSubscribeTextSensor final : public text_sensor::TextSensor, public Com protected: mqtt::MQTTClientComponent *parent_; - std::string topic_; + const char *topic_{nullptr}; uint8_t qos_{}; };