7static const char *
const TAG =
"template.select";
16 size_t restored_index;
17 if (this->
pref_.
load(&restored_index) && this->has_index(restored_index)) {
18 index = restored_index;
19 ESP_LOGD(TAG,
"State from restore: %s", this->
option_at(index));
21 ESP_LOGD(TAG,
"State from initial (could not load or invalid stored index): %s", this->
option_at(index));
24 ESP_LOGD(TAG,
"State from initial: %s", this->
option_at(index));
34 auto val = this->
f_();
35 if (
val.has_value()) {
37 ESP_LOGE(TAG,
"Lambda returned an invalid option: %s", (*val).c_str());
55 LOG_SELECT(
"",
"Template Select",
this);
56 LOG_UPDATE_INTERVAL(
this);
61 " Initial Option: %s\n"
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
uint32_t get_preference_hash()
Get a unique hash for storing preferences/settings for this entity.
bool has_value() const
Check if a lambda is set.
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
const char * option_at(size_t index) const
Return the option value at the provided index offset (as const char* from flash).
bool has_option(const std::string &option) const
Return whether this select component contains the provided option.
void publish_state(const std::string &state)
Trigger< std::string > * set_trigger_
void control(size_t index) override
void dump_config() override
ESPPreferenceObject pref_
size_t initial_option_index_
TemplateLambda< std::string > f_
Providing packet encoding functions for exchanging data with a remote host.
ESPPreferences * global_preferences