ESPHome  2024.12.0
switch_binary_sensor.cpp
Go to the documentation of this file.
1 #include "switch_binary_sensor.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace switch_ {
6 
7 static const char *const TAG = "switch.binary_sensor";
8 
10  source_->add_on_state_callback([this](bool value) { this->publish_state(value); });
11  this->publish_state(source_->state);
12 }
13 
14 void SwitchBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Switch Binary Sensor", this); }
15 
16 } // namespace switch_
17 } // namespace esphome
const char *const TAG
Definition: spi.cpp:8
void add_on_state_callback(std::function< void(bool)> &&callback)
Set callback for state changes.
Definition: switch.cpp:60
void publish_state(bool state)
Publish a new state to the front-end.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
The current reported state of the binary sensor.
Definition: switch.h:53