7 static const char *
const TAG =
"template.select";
10 if (this->
f_.has_value())
14 ESP_LOGD(TAG,
"Setting up Template Select");
17 ESP_LOGD(TAG,
"State from initial: %s", value.c_str());
23 ESP_LOGD(TAG,
"State from initial (could not load stored index): %s", value.c_str());
26 ESP_LOGD(TAG,
"State from initial (restored index %d out of bounds): %s", index, value.c_str());
28 value = this->
at(index).
value();
29 ESP_LOGD(TAG,
"State from restore: %s", value.c_str());
37 if (!this->
f_.has_value())
40 auto val = (*this->
f_)();
45 ESP_LOGE(TAG,
"Lambda returned an invalid option: %s", (*val).c_str());
65 LOG_SELECT(
"",
"Template Select",
this);
66 LOG_UPDATE_INTERVAL(
this);
67 if (this->
f_.has_value())
69 ESP_LOGCONFIG(TAG,
" Optimistic: %s", YESNO(this->
optimistic_));
70 ESP_LOGCONFIG(TAG,
" Initial Option: %s", this->
initial_option_.c_str());
71 ESP_LOGCONFIG(TAG,
" Restore Value: %s", YESNO(this->
restore_value_));
value_type const & value() const
bool has_option(const std::string &option) const
Return whether this select component contains the provided option.
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
optional< std::function< optional< std::string >)> > f_
std::string initial_option_
ESPPreferences * global_preferences
void control(const std::string &value) override
ESPPreferenceObject pref_
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
void publish_state(const std::string &state)
Implementation of SPI Controller mode.
bool has_index(size_t index) const
Return whether this select component contains the provided index offset.
optional< size_t > index_of(const std::string &option) const
Find the (optional) index offset of the provided option value.
void dump_config() override
uint32_t get_object_id_hash()
Trigger< std::string > * set_trigger_