ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
template_binary_sensor.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace template_ {
6
7static const char *const TAG = "template.binary_sensor";
8
10 if (!this->f_.has_value()) {
11 this->disable_loop();
12 } else {
13 this->loop();
14 }
15}
16
18 auto s = this->f_();
19 if (s.has_value()) {
20 this->publish_state(*s);
21 }
22}
23
24void TemplateBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Template Binary Sensor", this); }
25
26} // namespace template_
27} // namespace esphome
void disable_loop()
Disable this component's loop.
bool has_value() const
Check if a lambda is set.
void publish_state(bool new_state)
Publish a new state to the front-end.
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7