ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
copy_switch.cpp
Go to the documentation of this file.
1#include "copy_switch.h"
2#include "esphome/core/log.h"
3
4namespace esphome::copy {
5
6ESPHOME_LOG_TAG(TAG, "copy.switch");
7
9 source_->add_on_state_callback([this](float value) { this->publish_state(value); });
10
12}
13
14void CopySwitch::dump_config() { LOG_SWITCH("", "Copy Switch", this); }
15
16void CopySwitch::write_state(bool state) { this->source_->control(state); }
17
18} // namespace esphome::copy
switch_::Switch * source_
Definition copy_switch.h:17
void dump_config() override
void write_state(bool state) override
void add_on_state_callback(F &&callback)
Set callback for state changes.
Definition switch.h:101
bool state
The current reported state of the binary sensor.
Definition switch.h:60
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:70
void control(bool target_state)
Control this switch using a boolean state value.
Definition switch.cpp:12
bool state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "copy.binary_sensor")