ESPHome
2026.3.0-dev
Loading...
Searching...
No Matches
esphome
components
switch
binary_sensor
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::switch_
{
5
6
static
const
char
*
const
TAG
=
"switch.binary_sensor"
;
7
8
void
SwitchBinarySensor::setup
() {
9
source_
->
add_on_state_callback
([
this
](
bool
value) { this->
publish_state
(value); });
10
this->
publish_state
(
source_
->
state
);
11
}
12
13
void
SwitchBinarySensor::dump_config
() { LOG_BINARY_SENSOR(
""
,
"Switch Binary Sensor"
,
this
); }
14
15
}
// namespace esphome::switch_
esphome::binary_sensor::BinarySensor::publish_state
void publish_state(bool new_state)
Publish a new state to the front-end.
Definition
binary_sensor.cpp:20
esphome::switch_::SwitchBinarySensor::setup
void setup() override
Definition
switch_binary_sensor.cpp:8
esphome::switch_::SwitchBinarySensor::source_
Switch * source_
Definition
switch_binary_sensor.h:16
esphome::switch_::SwitchBinarySensor::dump_config
void dump_config() override
Definition
switch_binary_sensor.cpp:13
esphome::switch_::Switch::state
bool state
The current reported state of the binary sensor.
Definition
switch.h:55
esphome::switch_::Switch::add_on_state_callback
void add_on_state_callback(std::function< void(bool)> &&callback)
Set callback for state changes.
Definition
switch.cpp:72
log.h
esphome::spi::TAG
const char *const TAG
Definition
spi.cpp:7
esphome::switch_
Definition
automation.cpp:4
switch_binary_sensor.h
Generated by
1.12.0