ESPHome 2025.5.0
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 {
5namespace copy {
6
7static const char *const TAG = "copy.switch";
8
10 source_->add_on_state_callback([this](float value) { this->publish_state(value); });
11
13}
14
15void CopySwitch::dump_config() { LOG_SWITCH("", "Copy Switch", this); }
16
18 if (state) {
20 } else {
22 }
23}
24
25} // namespace copy
26} // namespace esphome
switch_::Switch * source_
Definition copy_switch.h:19
void dump_config() override
void write_state(bool state) override
void turn_on()
Turn this switch on.
Definition switch.cpp:11
void turn_off()
Turn this switch off.
Definition switch.cpp:15
bool state
The current reported state of the binary sensor.
Definition switch.h:53
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 state to the front-end from the back-end.
Definition switch.cpp:47
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7