ESPHome 2026.6.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
6static const char *const 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
17 if (state) {
19 } else {
21 }
22}
23
24} // 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:96
void turn_on()
Turn this switch on.
Definition switch.cpp:20
void turn_off()
Turn this switch off.
Definition switch.cpp:24
bool state
The current reported state of the binary sensor.
Definition switch.h:55
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:56
bool state
Definition fan.h:2