ESPHome
2024.10.2
esphome
esphome
components
template
text_sensor
template_text_sensor.cpp
Go to the documentation of this file.
1
#include "
template_text_sensor.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome
{
5
namespace
template_ {
6
7
static
const
char
*
const
TAG
=
"template.text_sensor"
;
8
9
void
TemplateTextSensor::update
() {
10
if
(!this->
f_
.has_value())
11
return
;
12
13
auto
val
= (*this->
f_
)();
14
if
(
val
.has_value()) {
15
this->
publish_state
(*
val
);
16
}
17
}
18
float
TemplateTextSensor::get_setup_priority
()
const
{
return
setup_priority::HARDWARE
; }
19
void
TemplateTextSensor::set_template
(std::function<
optional<std::string>
()> &&f) { this->
f_
= f; }
20
void
TemplateTextSensor::dump_config
() { LOG_TEXT_SENSOR(
""
,
"Template Sensor"
,
this
); }
21
22
}
// namespace template_
23
}
// namespace esphome
esphome::template_::TemplateTextSensor::f_
optional< std::function< optional< std::string >)> > f_
Definition:
template_text_sensor.h:21
esphome::template_::TemplateTextSensor::update
void update() override
Definition:
template_text_sensor.cpp:9
val
mopeka_std_values val[4]
Definition:
mopeka_std_check.h:224
esphome::text_sensor::TextSensor::publish_state
void publish_state(const std::string &state)
Definition:
text_sensor.cpp:9
esphome::template_::TemplateTextSensor::dump_config
void dump_config() override
Definition:
template_text_sensor.cpp:20
esphome::template_::TemplateTextSensor::get_setup_priority
float get_setup_priority() const override
Definition:
template_text_sensor.cpp:18
esphome::spi::TAG
const char *const TAG
Definition:
spi.cpp:8
esphome::template_::TemplateTextSensor::set_template
void set_template(std::function< optional< std::string >()> &&f)
Definition:
template_text_sensor.cpp:19
template_text_sensor.h
esphome::optional< std::string >
esphome::setup_priority::HARDWARE
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition:
component.cpp:18
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
log.h
Generated by
1.8.13