7 static const char *
const TAG =
"select";
12 if (index.has_value()) {
15 ESP_LOGD(TAG,
"'%s': Sending state %s (index %zu)",
name, state.c_str(), index.value());
18 ESP_LOGE(TAG,
"'%s': invalid state for publish_state(): %s",
name, state.c_str());
41 return std::distance(
options.begin(), it);
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.
CallbackManager< void(std::string, size_t)> state_callback_
optional< size_t > active_index() const
Return the (optional) index offset of the currently active option.
std::vector< std::string > get_options() const
size_t size() const
Return the number of options in this select component.
constexpr const char * c_str() const
void publish_state(const std::string &state)
Implementation of SPI Controller mode.
bool has_state() const
Return whether this select component has gotten a full state yet.
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 add_on_state_callback(std::function< void(std::string, size_t)> &&callback)
const StringRef & get_name() const