[select] Store options in flash to reduce RAM usage (#11514)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2025-10-29 15:28:16 +13:00
1 parent a609343cb6
commit f3634edc22
15 files changed
+111 -40

No files matched your search

@@ -16,12 +16,12 @@ void TemplateSelect::setup() {
size_t restored_index;
if (this->pref_.load(&restored_index) && this->has_index(restored_index)) {
index = restored_index;
ESP_LOGD(TAG, "State from restore: %s", this->at(index).value().c_str());
ESP_LOGD(TAG, "State from restore: %s", this->option_at(index));
} else {
ESP_LOGD(TAG, "State from initial (could not load or invalid stored index): %s", this->at(index).value().c_str());
ESP_LOGD(TAG, "State from initial (could not load or invalid stored index): %s", this->option_at(index));
}
} else {
ESP_LOGD(TAG, "State from initial: %s", this->at(index).value().c_str());
ESP_LOGD(TAG, "State from initial: %s", this->option_at(index));
}
this->publish_state(this->at(index).value());
@@ -64,8 +64,7 @@ void TemplateSelect::dump_config() {
" Optimistic: %s\n"
" Initial Option: %s\n"
" Restore Value: %s",
YESNO(this->optimistic_), this->at(this->initial_option_index_).value().c_str(),
YESNO(this->restore_value_));
YESNO(this->optimistic_), this->option_at(this->initial_option_index_), YESNO(this->restore_value_));
}
} // namespace template_