ESPHome 2026.2.1
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 LOG_ENTITY_ICON(TAG, prefix, *(obj)); \
16 }
17
22class Text : public EntityBase {
23 public:
24 std::string state;
26
27 void publish_state(const std::string &state);
28 void publish_state(const char *state);
29 void publish_state(const char *state, size_t len);
30
32 TextCall make_call() { return TextCall(this); }
33
34 void add_on_state_callback(std::function<void(const std::string &)> &&callback);
35
36 protected:
37 friend class TextCall;
38
45 virtual void control(const std::string &value) = 0;
46
47 LazyCallbackManager<void(const std::string &)> state_callback_;
48};
49
50} // namespace text
51} // namespace esphome
Base-class for all text inputs.
Definition text.h:22
LazyCallbackManager< void(const std::string &)> state_callback_
Definition text.h:47
void publish_state(const std::string &state)
Definition text.cpp:12
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...
std::string state
Definition text.h:24
void add_on_state_callback(std::function< void(const std::string &)> &&callback)
Definition text.cpp:33
TextTraits traits
Definition text.h:25
friend class TextCall
Definition text.h:37
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:692