ESPHome  2024.10.2
copy_binary_sensor.cpp
Go to the documentation of this file.
1 #include "copy_binary_sensor.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace copy {
6 
7 static const char *const TAG = "copy.binary_sensor";
8 
10  source_->add_on_state_callback([this](bool value) { this->publish_state(value); });
11  if (source_->has_state())
12  this->publish_state(source_->state);
13 }
14 
15 void CopyBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Copy Binary Sensor", this); }
16 
17 } // namespace copy
18 } // namespace esphome
binary_sensor::BinarySensor * source_
virtual bool has_state() const
Return whether this binary sensor has outputted a state.
bool state
The current reported state of the binary sensor.
Definition: binary_sensor.h:61
void publish_state(bool state)
Publish a new state to the front-end.
void add_on_state_callback(std::function< void(bool)> &&callback)
Add a callback to be notified of state changes.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7