1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-24 13:58:14 +00:00
esphome/esphome/components/mqtt/mqtt_text_sensor.h
Pauline Middelink 071272a27f Fix mqtt_text_sensor to honor unique_id when set. (#698)
* Fix mqtt_text_sensor to honor unique_id when set.
* Remove setting of unique_id in json tree, as the mqtt_component already does this, and in fact overrides what we do here.
* Add unqiue_id() and dump_config() to the wifi_info sensors.
2019-08-27 10:28:50 -07:00

43 lines
819 B
C++

#pragma once
#include "esphome/core/defines.h"
#ifdef USE_TEXT_SENSOR
#include "esphome/components/text_sensor/text_sensor.h"
#include "mqtt_component.h"
namespace esphome {
namespace mqtt {
class MQTTTextSensor : public mqtt::MQTTComponent {
public:
explicit MQTTTextSensor(text_sensor::TextSensor *sensor);
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override;
void setup() override;
void dump_config() override;
bool publish_state(const std::string &value);
bool send_initial_state() override;
bool is_internal() override;
protected:
std::string component_type() const override;
std::string friendly_name() const override;
std::string unique_id() override;
text_sensor::TextSensor *sensor_;
};
} // namespace mqtt
} // namespace esphome
#endif