ESPHome
2025.5.0
Loading...
Searching...
No Matches
esphome
components
text
text.cpp
Go to the documentation of this file.
1
#include "
text.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome
{
5
namespace
text {
6
7
static
const
char
*
const
TAG
=
"text"
;
8
9
void
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
21
void
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
esphome::EntityBase::get_name
const StringRef & get_name() const
Definition
entity_base.cpp:10
esphome::text::Text::has_state_
bool has_state_
Definition
text.h:51
esphome::text::Text::publish_state
void publish_state(const std::string &state)
Definition
text.cpp:9
esphome::text::Text::add_on_state_callback
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition
text.cpp:21
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:50
esphome::text::TextTraits::get_mode
TextMode get_mode() const
Definition
text_traits.h:29
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:12
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
text.h
Generated by
1.12.0