ESPHome  2022.6.2
template_binary_sensor.cpp
Go to the documentation of this file.
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace template_ {
6 
7 static const char *const TAG = "template.binary_sensor";
8 
10  if (!this->f_.has_value())
11  return;
12 
13  auto s = (*this->f_)();
14  if (s.has_value()) {
15  this->publish_state(*s);
16  }
17 }
18 void TemplateBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Template Binary Sensor", this); }
19 
20 } // namespace template_
21 } // namespace esphome
optional< std::function< optional< bool >)> > f_
void publish_state(bool state)
Publish a new state to the front-end.
Definition: a4988.cpp:4