ESPHome
2025.9.0-dev
Loading...
Searching...
No Matches
esphome
components
template
binary_sensor
template_binary_sensor.cpp
Go to the documentation of this file.
1
#include "
template_binary_sensor.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome
{
5
namespace
template_ {
6
7
static
const
char
*
const
TAG
=
"template.binary_sensor"
;
8
9
void
TemplateBinarySensor::setup
() { this->
loop
(); }
10
11
void
TemplateBinarySensor::loop
() {
12
if
(this->
f_
==
nullptr
)
13
return
;
14
15
auto
s = this->
f_
();
16
if
(s.has_value()) {
17
this->
publish_state
(*s);
18
}
19
}
20
void
TemplateBinarySensor::dump_config
() { LOG_BINARY_SENSOR(
""
,
"Template Binary Sensor"
,
this
); }
21
22
}
// namespace template_
23
}
// namespace esphome
esphome::binary_sensor::BinarySensor::publish_state
void publish_state(bool new_state)
Publish a new state to the front-end.
Definition
binary_sensor.cpp:10
esphome::template_::TemplateBinarySensor::f_
std::function< optional< bool >()> f_
Definition
template_binary_sensor.h:20
esphome::template_::TemplateBinarySensor::dump_config
void dump_config() override
Definition
template_binary_sensor.cpp:20
esphome::template_::TemplateBinarySensor::loop
void loop() override
Definition
template_binary_sensor.cpp:11
esphome::template_::TemplateBinarySensor::setup
void setup() override
Definition
template_binary_sensor.cpp:9
log.h
esphome::spi::TAG
const char *const TAG
Definition
spi.cpp:8
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
template_binary_sensor.h
Generated by
1.12.0