23template<
bool HAS_LAMBDA,
bool OPTIMISTIC,
bool RESTORE_VALUE,
size_t INITIAL_OPTION_INDEX>
27 if constexpr (HAS_LAMBDA) {
28 this->
f_.set(std::forward<F>(
f));
33 if constexpr (!HAS_LAMBDA) {
34 if constexpr (RESTORE_VALUE) {
44 if constexpr (HAS_LAMBDA) {
55 if constexpr (OPTIMISTIC)
57 if constexpr (RESTORE_VALUE)
58 this->
pref_.save(&index);
60 [[no_unique_address]] std::conditional_t<HAS_LAMBDA, TemplateLambda<std::string>,
Empty>
f_{};
61 [[no_unique_address]] std::conditional_t<RESTORE_VALUE, ESPPreferenceObject, Empty>
pref_{};
65template<
bool HAS_LAMBDA,
bool OPTIMISTIC,
bool RESTORE_VALUE,
size_t INITIAL_OPTION_INDEX>
67 :
public TemplateSelect<HAS_LAMBDA, OPTIMISTIC, RESTORE_VALUE, INITIAL_OPTION_INDEX> {
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && f
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
This class simplifies creating components that periodically check a state.
StringRef is a reference to a string owned by something else.
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
Base-class for all selects.
const char * option_at(size_t index) const
Return the option value at the provided index offset (as const char* from flash).
void publish_state(const std::string &state)
Base template select class - used when no set_action is configured.
void control(size_t index) override
float get_setup_priority() const override
std::conditional_t< RESTORE_VALUE, ESPPreferenceObject, Empty > pref_
void dump_config() override
std::conditional_t< HAS_LAMBDA, TemplateLambda< std::string >, Empty > f_
Template select with set_action trigger - only instantiated when set_action is configured.
void control(size_t index) override
Trigger< StringRef > set_trigger_
Trigger< StringRef > * get_set_trigger()
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
void update_lambda(BaseTemplateSelect *sel_comp, const optional< std::string > &val)
void dump_config_helper(BaseTemplateSelect *sel_comp, bool optimistic, bool has_lambda, const size_t initial_option_index, bool restore_value)
void setup_initial(BaseTemplateSelect *sel_comp, size_t initial_index)
void setup_with_restore(BaseTemplateSelect *sel_comp, ESPPreferenceObject &pref, size_t initial_index)