ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
switch_binary_sensor.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome::switch_ {
5
6static const char *const TAG = "switch.binary_sensor";
7
9 source_->add_on_state_callback([this](bool value) { this->publish_state(value); });
11}
12
13void SwitchBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Switch Binary Sensor", this); }
14
15} // namespace esphome::switch_
void publish_state(bool new_state)
Publish a new state to the front-end.
bool state
The current reported state of the binary sensor.
Definition switch.h:55
void add_on_state_callback(std::function< void(bool)> &&callback)
Set callback for state changes.
Definition switch.cpp:72
const char *const TAG
Definition spi.cpp:7