ESPHome  2024.9.2
copy_text.cpp
Go to the documentation of this file.
1 #include "copy_text.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace copy {
6 
7 static const char *const TAG = "copy.text";
8 
10  source_->add_on_state_callback([this](const std::string &value) { this->publish_state(value); });
11 
12  if (source_->has_state())
13  this->publish_state(source_->state);
14 }
15 
16 void CopyText::dump_config() { LOG_TEXT("", "Copy Text", this); }
17 
18 void CopyText::control(const std::string &value) {
19  auto call2 = source_->make_call();
20  call2.set_value(value);
21  call2.perform();
22 }
23 
24 } // namespace copy
25 } // namespace esphome
std::string state
Definition: text.h:26
TextCall & set_value(const std::string &value)
Definition: text_call.cpp:10
void setup() override
Definition: copy_text.cpp:9
void dump_config() override
Definition: copy_text.cpp:16
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
Definition: text.h:35
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition: text.cpp:21
bool has_state() const
Return whether this text input has gotten a full state yet.
Definition: text.h:32
void publish_state(const std::string &state)
Definition: text.cpp:9
text::Text * source_
Definition: copy_text.h:19
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void control(const std::string &value) override
Definition: copy_text.cpp:18