9static const char *
const TAG =
"select";
15 if (index.has_value()) {
18 ESP_LOGE(TAG,
"'%s': Invalid option %s", this->
get_name().c_str(),
state);
24 ESP_LOGE(TAG,
"'%s': Invalid index %zu", this->
get_name().c_str(), index);
27 const char *option = this->
option_at(index);
30#pragma GCC diagnostic push
31#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
33#pragma GCC diagnostic pop
34 ESP_LOGD(TAG,
"'%s': Sending state %s (index %zu)", this->
get_name().c_str(), option, index);
37#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)
61 for (
size_t i = 0; i <
options.size(); i++) {
79 return std::string(
options.at(index));
static void notify_select_update(select::Select *obj)
const StringRef & get_name() const
void set_has_state(bool state)
T & at(size_t i)
Access element with bounds checking (matches std::vector behavior) Note: No exception thrown on out o...
void add_on_state_callback(std::function< void(std::string, size_t)> &&callback)
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.
size_t size() const
Return the number of options in this select component.
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.
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.
const char * current_option() const
Return the currently selected option (as const char* from flash).
CallbackManager< void(std::string, size_t)> state_callback_
void publish_state(const std::string &state)
const FixedVector< const char * > & get_options() const