1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-15 14:25:45 +00:00
Files
esphome/esphome/components/copy/select/copy_select.cpp
J. Nick Koston b6d178b8c1 cleanups
2025-10-30 13:12:28 -05:00

28 lines
667 B
C++

#include "copy_select.h"
#include "esphome/core/log.h"
namespace esphome {
namespace copy {
static const char *const TAG = "copy.select";
void CopySelect::setup() {
source_->add_on_state_callback([this](const std::string &value, size_t index) { this->publish_state(index); });
traits.set_options(source_->traits.get_options());
if (source_->has_state())
this->publish_state(source_->active_index().value());
}
void CopySelect::dump_config() { LOG_SELECT("", "Copy Select", this); }
void CopySelect::control(size_t index) {
auto call = source_->make_call();
call.set_index(index);
call.perform();
}
} // namespace copy
} // namespace esphome