ESPHome 2026.1.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::template_ {
5
6static const char *const TAG = "template.binary_sensor";
7
9 if (!this->f_.has_value()) {
10 this->disable_loop();
11 } else {
12 this->loop();
13 }
14}
15
17 auto s = this->f_();
18 if (s.has_value()) {
19 this->publish_state(*s);
20 }
21}
22
23void TemplateBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Template Binary Sensor", this); }
24
25} // namespace esphome::template_
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:7