ESPHome 2025.5.0
Loading...
Searching...
No Matches
text.cpp
Go to the documentation of this file.
1#include "text.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace text {
6
7static const char *const TAG = "text";
8
9void Text::publish_state(const std::string &state) {
10 this->has_state_ = true;
11 this->state = state;
12 if (this->traits.get_mode() == TEXT_MODE_PASSWORD) {
13 ESP_LOGD(TAG, "'%s': Sending state " LOG_SECRET("'%s'"), this->get_name().c_str(), state.c_str());
14
15 } else {
16 ESP_LOGD(TAG, "'%s': Sending state %s", this->get_name().c_str(), state.c_str());
17 }
18 this->state_callback_.call(state);
19}
20
21void Text::add_on_state_callback(std::function<void(std::string)> &&callback) {
22 this->state_callback_.add(std::move(callback));
23}
24
25} // namespace text
26} // namespace esphome
const StringRef & get_name() const
void publish_state(const std::string &state)
Definition text.cpp:9
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:50
TextMode get_mode() const
Definition text_traits.h:29
bool state
Definition fan.h:0
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7