7static const char *
const TAG =
"template.select";
10 if (this->
f_.has_value())
16 ESP_LOGD(TAG,
"State from initial: %s", value.c_str());
22 ESP_LOGD(TAG,
"State from initial (could not load stored index): %s", value.c_str());
25 ESP_LOGD(TAG,
"State from initial (restored index %d out of bounds): %s", index, value.c_str());
27 value = this->
at(index).
value();
28 ESP_LOGD(TAG,
"State from restore: %s", value.c_str());
36 if (!this->
f_.has_value())
39 auto val = (*this->
f_)();
44 ESP_LOGE(TAG,
"Lambda returned an invalid option: %s", (*val).c_str());
64 LOG_SELECT(
"",
"Template Select",
this);
65 LOG_UPDATE_INTERVAL(
this);
66 if (this->
f_.has_value())
70 " Initial Option: %s\n"
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
uint32_t get_object_id_hash()
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
value_type const & value() const
optional< size_t > index_of(const std::string &option) const
Find the (optional) index offset of the provided option value.
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
bool has_option(const std::string &option) const
Return whether this select component contains the provided option.
bool has_index(size_t index) const
Return whether this select component contains the provided index offset.
void publish_state(const std::string &state)
Trigger< std::string > * set_trigger_
std::string initial_option_
void dump_config() override
void control(const std::string &value) override
ESPPreferenceObject pref_
optional< std::function< optional< std::string >()> > f_
Providing packet encoding functions for exchanging data with a remote host.
ESPPreferences * global_preferences