ESPHome 2026.11.0b6
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 this->source_switch_->add_on_state_callback([this](float value) { this->publish_state(value); });
10
11 this->publish_state(this->source_switch_->state);
12}
13
14void CopySwitch::dump_config() { LOG_SWITCH("", "Copy Switch", this); }
15
16void CopySwitch::write_state(bool state) { this->source_switch_->control(state); }
17
18} // namespace esphome::copy
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
void write_state(bool state) override
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:75
bool state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "copy.binary_sensor")
uint32_t value
Definition hal.cpp:41