1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 23:21:54 +00:00

[select] Store options in flash to reduce RAM usage

This commit is contained in:
J. Nick Koston
2025-10-24 04:22:22 -07:00
parent d27e78e909
commit 3d6224d1b1
3 changed files with 4 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ void CopySelect::setup() {
source_->add_on_state_callback([this](const std::string &value, size_t index) { this->publish_state(value); });
const auto &source_options = source_->traits.get_options();
traits.set_options({source_options.begin(), source_options.end()});
traits.set_options(source_options);
if (source_->has_state())
this->publish_state(source_->state);

View File

@@ -5,6 +5,8 @@ namespace select {
void SelectTraits::set_options(std::initializer_list<const char *> options) { this->options_ = options; }
void SelectTraits::set_options(const FixedVector<const char *> &options) { this->options_ = options; }
const FixedVector<const char *> &SelectTraits::get_options() const { return this->options_; }
} // namespace select

View File

@@ -9,6 +9,7 @@ namespace select {
class SelectTraits {
public:
void set_options(std::initializer_list<const char *> options);
void set_options(const FixedVector<const char *> &options);
const FixedVector<const char *> &get_options() const;
protected: