ESPHome
2024.11.0
esphome
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::text::Text::has_state_
bool has_state_
Definition:
text.h:51
esphome::text::TextTraits::get_mode
TextMode get_mode() const
Definition:
text_traits.h:29
esphome::text::Text::state
std::string state
Definition:
text.h:26
esphome::text::Text::traits
TextTraits traits
Definition:
text.h:27
text.h
esphome::text::Text::state_callback_
CallbackManager< void(std::string)> state_callback_
Definition:
text.h:50
esphome::spi::TAG
const char *const TAG
Definition:
spi.cpp:8
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_MODE_PASSWORD
Definition:
text_traits.h:12
esphome::text::Text::publish_state
void publish_state(const std::string &state)
Definition:
text.cpp:9
esphome::StringRef::c_str
constexpr const char * c_str() const
Definition:
string_ref.h:68
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
log.h
esphome::EntityBase::get_name
const StringRef & get_name() const
Definition:
entity_base.cpp:10
state
bool state
Definition:
fan.h:34
Generated by
1.8.13