13 if (index.has_value()) {
16 ESP_LOGE(TAG,
"'%s': Invalid option %s", LOG_STR_ARG(this->
get_log_name()), state);
22 ESP_LOGE(TAG,
"'%s': Invalid index %zu", LOG_STR_ARG(this->
get_log_name()), index);
25 const char *option = this->
option_at(index);
28 ESP_LOGV(TAG,
"'%s' >> %s (%zu)", LOG_STR_ARG(this->
get_log_name()), option, index);
30#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)
31 ControllerRegistry::notify_select_update(
this);
37 for (
size_t i = 0; i <
options.size(); i++) {
55 return std::string(
options.at(index));
const T & at(size_t i) const
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
void set_has_state(bool state)
const char * option_at(size_t index) const
Return the option value at the provided index offset (as const char* from flash).
optional< size_t > active_index() const
Return the (optional) index offset of the currently active option.
LazyCallbackManager< void(size_t)> state_callback_
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
optional< size_t > index_of(const char *option, size_t len) const
Find the (optional) index offset of the provided option value.
bool has_index(size_t index) const
Return whether this select component contains the provided index offset.
void publish_state(const std::string &state)
const SelectOptions & get_options() const
ESPHOME_LOG_TAG(TAG, "select")