ESPHome
2025.12.0-dev
Loading...
Searching...
No Matches
esphome
components
text
text.cpp
Go to the documentation of this file.
1
#include "
text.h
"
2
#include "
esphome/core/defines.h
"
3
#include "
esphome/core/controller_registry.h
"
4
#include "
esphome/core/log.h
"
5
6
namespace
esphome
{
7
namespace
text {
8
9
static
const
char
*
const
TAG
=
"text"
;
10
11
void
Text::publish_state
(
const
std::string &
state
) {
12
this->
set_has_state
(
true
);
13
this->state =
state
;
14
if
(this->
traits
.
get_mode
() ==
TEXT_MODE_PASSWORD
) {
15
ESP_LOGD(TAG,
"'%s': Sending state "
LOG_SECRET(
"'%s'"
), this->
get_name
().c_str(),
state
.c_str());
16
17
}
else
{
18
ESP_LOGD(TAG,
"'%s': Sending state %s"
, this->
get_name
().c_str(),
state
.c_str());
19
}
20
this->
state_callback_
.call(state);
21
#if defined(USE_TEXT) && defined(USE_CONTROLLER_REGISTRY)
22
ControllerRegistry::notify_text_update
(
this
);
23
#endif
24
}
25
26
void
Text::add_on_state_callback
(std::function<
void
(std::string)> &&callback) {
27
this->
state_callback_
.add(std::move(callback));
28
}
29
30
}
// namespace text
31
}
// namespace esphome
esphome::ControllerRegistry::notify_text_update
static void notify_text_update(text::Text *obj)
esphome::EntityBase::get_name
const StringRef & get_name() const
Definition
entity_base.cpp:11
esphome::EntityBase::set_has_state
void set_has_state(bool state)
Definition
entity_base.h:93
esphome::text::Text::publish_state
void publish_state(const std::string &state)
Definition
text.cpp:11
esphome::text::Text::add_on_state_callback
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition
text.cpp:26
esphome::text::Text::state
std::string state
Definition
text.h:26
esphome::text::Text::traits
TextTraits traits
Definition
text.h:27
esphome::text::Text::state_callback_
CallbackManager< void(std::string)> state_callback_
Definition
text.h:47
esphome::text::TextTraits::get_mode
TextMode get_mode() const
Definition
text_traits.h:31
controller_registry.h
defines.h
state
bool state
Definition
fan.h:0
log.h
esphome::spi::TAG
const char *const TAG
Definition
spi.cpp:8
esphome::text::TEXT_MODE_PASSWORD
@ TEXT_MODE_PASSWORD
Definition
text_traits.h:13
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
text.h
Generated by
1.12.0