mirror of
https://github.com/esphome/esphome.git
synced 2026-10-22 05:46:12 +00:00
[mqtt_subscribe] Stop copying the topic (#21207)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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};
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_{};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user