ESPHome 2026.3.0-dev
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::text {
10
11#define LOG_TEXT(prefix, type, obj) \
12 if ((obj) != nullptr) { \
13 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
14 LOG_ENTITY_ICON(TAG, prefix, *(obj)); \
15 }
16
21class Text : public EntityBase {
22 public:
23 std::string state;
25
26 void publish_state(const std::string &state);
27 void publish_state(const char *state);
28 void publish_state(const char *state, size_t len);
29
31 TextCall make_call() { return TextCall(this); }
32
33 void add_on_state_callback(std::function<void(const std::string &)> &&callback);
34
35 protected:
36 friend class TextCall;
37
44 virtual void control(const std::string &value) = 0;
45
46 LazyCallbackManager<void(const std::string &)> state_callback_;
47};
48
49} // namespace esphome::text
Base-class for all text inputs.
Definition text.h:21
LazyCallbackManager< void(const std::string &)> state_callback_
Definition text.h:46
void publish_state(const std::string &state)
Definition text.cpp:11
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
Definition text.h:31
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:23
void add_on_state_callback(std::function< void(const std::string &)> &&callback)
Definition text.cpp:32
TextTraits traits
Definition text.h:24
friend class TextCall
Definition text.h:36
std::string size_t len
Definition helpers.h:817