ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
copy_select.cpp
Go to the documentation of this file.
1#include "copy_select.h"
2#include "esphome/core/log.h"
3
4namespace esphome::copy {
5
6ESPHOME_LOG_TAG(TAG, "copy.select");
7
9 this->source_select_->add_on_state_callback([this](size_t index) { this->publish_state(index); });
10
11 traits.set_options(this->source_select_->traits.get_options());
12
13 auto idx = this->source_select_->active_index();
14 if (idx.has_value())
15 this->publish_state(*idx);
16}
17
18void CopySelect::dump_config() { LOG_SELECT("", "Copy Select", this); }
19
20void CopySelect::control(size_t index) {
21 auto call = this->source_select_->make_call();
22 call.set_index(index);
23 call.perform();
24}
25
26} // namespace esphome::copy
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
void control(size_t index) override
SelectTraits traits
Definition select.h:30
void publish_state(const std::string &state)
Definition select.h:35
void set_options(const SelectOptions &options)
Runtime lists: the pointer list is copied, as before; the strings must still outlive the select.
ESPHOME_LOG_TAG(TAG, "copy.binary_sensor")