ESPHome  2024.4.1
mqtt_text_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/defines.h"
4 
5 #ifdef USE_MQTT
6 #ifdef USE_TEXT_SENSOR
7 
9 #include "mqtt_component.h"
10 
11 namespace esphome {
12 namespace mqtt {
13 
15  public:
16  explicit MQTTTextSensor(text_sensor::TextSensor *sensor);
17 
18  void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
19 
20  void setup() override;
21 
22  void dump_config() override;
23 
24  bool publish_state(const std::string &value);
25 
26  bool send_initial_state() override;
27 
28  protected:
29  std::string component_type() const override;
30  const EntityBase *get_entity() const override;
31  std::string unique_id() override;
32 
34 };
35 
36 } // namespace mqtt
37 } // namespace esphome
38 
39 #endif
40 #endif // USE_MQTT
MQTTTextSensor(text_sensor::TextSensor *sensor)
std::string unique_id() override
bool publish_state(const std::string &value)
Simple Helper struct used for Home Assistant MQTT send_discovery().
const EntityBase * get_entity() const override
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
text_sensor::TextSensor * sensor_
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
std::string component_type() const override
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...