ESPHome 2025.5.0
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->publish_initial_state_)
11 return;
12
13 if (this->f_ != nullptr) {
14 this->publish_initial_state(this->f_().value_or(false));
15 } else {
16 this->publish_initial_state(false);
17 }
18}
20 if (this->f_ == nullptr)
21 return;
22
23 auto s = this->f_();
24 if (s.has_value()) {
25 this->publish_state(*s);
26 }
27}
28void TemplateBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Template Binary Sensor", this); }
29
30} // namespace template_
31} // namespace esphome
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
void publish_state(bool state)
Publish a new state to the front-end.
std::function< optional< bool >()> f_
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7