10static const char *
const TAG =
"select";
16 if (index.has_value()) {
19 ESP_LOGE(TAG,
"'%s': Invalid option %s", this->
get_name().c_str(),
state);
25 ESP_LOGE(TAG,
"'%s': Invalid index %zu", this->
get_name().c_str(), index);
28 const char *option = this->
option_at(index);
31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
34#pragma GCC diagnostic pop
35 ESP_LOGD(TAG,
"'%s': Sending state %s (index %zu)", this->
get_name().c_str(), option, index);
38#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)
64 for (
size_t i = 0; i <
options.size(); i++) {
65 if (strcmp(
options[i], option) == 0) {
82 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< 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.
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
Providing packet encoding functions for exchanging data with a remote host.