[select] Refactor to index-based operations for immediate and future RAM savings (#11623)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2025-11-05 11:33:01 +13:00
1 parent c7ae424613
commit 6f7e54c3f3
44 files changed
+268 -204

No files matched your search

@@ -24,7 +24,7 @@ void TemplateSelect::setup() {
ESP_LOGD(TAG, "State from initial: %s", this->option_at(index));
}
this->publish_state(this->at(index).value());
this->publish_state(index);
}
void TemplateSelect::update() {
@@ -41,16 +41,14 @@ void TemplateSelect::update() {
}
}
void TemplateSelect::control(const std::string &value) {
this->set_trigger_->trigger(value);
void TemplateSelect::control(size_t index) {
this->set_trigger_->trigger(std::string(this->option_at(index)));
if (this->optimistic_)
this->publish_state(value);
this->publish_state(index);
if (this->restore_value_) {
auto index = this->index_of(value);
this->pref_.save(&index.value());
}
if (this->restore_value_)
this->pref_.save(&index);
}
void TemplateSelect::dump_config() {