ESPHome 2025.6.0
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1#pragma once
2
6#include "text_call.h"
7#include "text_traits.h"
8
9namespace esphome {
10namespace text {
11
12#define LOG_TEXT(prefix, type, obj) \
13 if ((obj) != nullptr) { \
14 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
15 if (!(obj)->get_icon().empty()) { \
16 ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
17 } \
18 }
19
24class Text : public EntityBase {
25 public:
26 std::string state;
28
29 void publish_state(const std::string &state);
30
32 TextCall make_call() { return TextCall(this); }
33
34 void add_on_state_callback(std::function<void(std::string)> &&callback);
35
36 protected:
37 friend class TextCall;
38
45 virtual void control(const std::string &value) = 0;
46
47 CallbackManager<void(std::string)> state_callback_;
48};
49
50} // namespace text
51} // namespace esphome
Base-class for all text inputs.
Definition text.h:24
void publish_state(const std::string &state)
Definition text.cpp:9
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
Definition text.h:32
virtual void control(const std::string &value)=0
Set the value of the text input, this is a virtual method that each text input integration must imple...
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition text.cpp:21
std::string state
Definition text.h:26
TextTraits traits
Definition text.h:27
CallbackManager< void(std::string)> state_callback_
Definition text.h:47
friend class TextCall
Definition text.h:37
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7