12#define LOG_SELECT(prefix, type, obj) \
13 if ((obj) != nullptr) { \
14 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
15 if (!(obj)->get_icon_ref().empty()) { \
16 ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon_ref().c_str()); \
20#define SUB_SELECT(name) \
22 select::Select *name##_select_{nullptr}; \
25 void set_##name##_select(select::Select *select) { this->name##_select_ = select; }
35#pragma GCC diagnostic push
36#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
38 ESPDEPRECATED(
"Use current_option() instead of .state. Will be removed in 2026.5.0",
"2025.11.0")
43#pragma GCC diagnostic pop
56 bool has_option(
const std::string &option)
const;
76 const char *
option_at(
size_t index)
const;
107 virtual void control(
const std::string &value) {
109 if (index.has_value()) {
Base-class for all selects.
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).
SelectCall make_call()
Instantiate a SelectCall object to modify this select component's state.
virtual void control(size_t index)
Set the value of the select by index, this is an optional virtual method.
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).
virtual void control(const std::string &value)
Set the value of the select, this is a virtual method that each select integration can implement.
ESPDEPRECATED("Use current_option() instead of .state. Will be removed in 2026.5.0", "2025.11.0") std Select()=default
CallbackManager< void(std::string, size_t)> state_callback_
void publish_state(const std::string &state)
Providing packet encoding functions for exchanging data with a remote host.