19#if defined(__GNUC__) || defined(__clang__)
20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
24template<
int...>
struct ESPDEPRECATED(
"Use std::index_sequence instead. Removed in 2026.6.0",
"2025.12.0")
seq {};
25template<
int N,
int... S>
26struct ESPDEPRECATED(
"Use std::make_index_sequence instead. Removed in 2026.6.0",
"2025.12.0") gens
27 : gens<N - 1, N - 1, S...> {};
28template<
int... S>
struct gens<0, S...> {
using type =
seq<S...>; };
30#if defined(__GNUC__) || defined(__clang__)
31#pragma GCC diagnostic pop
35#define TEMPLATABLE_VALUE_(type, name) \
37 TemplatableValue<type, Ts...> name##_{}; \
40 template<typename V> void set_##name(V name) { this->name##_ = name; }
42#define TEMPLATABLE_VALUE(type, name) TEMPLATABLE_VALUE_(type, name)
60 TemplatableValue(F f)
requires std::invocable<F, X...> && std::convertible_to<F, T (*)(X...)>
68 this->
f_ =
new std::function<T(X...)>(std::move(f));
76 this->
f_ =
new std::function<T(X...)>(*other.
f_);
87 new (&this->
value_) T(std::move(other.value_));
101 if (
this != &other) {
109 if (
this != &other) {
128 switch (this->
type_) {
132 return (*this->
f_)(
x...);
138 if constexpr (std::same_as<T, std::string>) {
141 __builtin_unreachable();
157 return default_value;
173 std::function<T(X...)> *
f_;
190 return this->
check_tuple_(tuple, std::make_index_sequence<
sizeof...(Ts)>{});
194 template<
size_t... S>
bool check_tuple_(
const std::tuple<Ts...> &tuple, std::index_sequence<S...> ) {
195 return this->
check(std::get<S>(tuple)...);
199template<
typename... Ts>
class Automation;
228template<
typename... Ts>
class ActionList;
251 if (this->
next_ !=
nullptr)
260 virtual void play(
const Ts &...
x) = 0;
264 if (this->
next_ !=
nullptr) {
269 template<
size_t... S>
void play_next_tuple_(
const std::tuple<Ts...> &tuple, std::index_sequence<S...> ) {
278 if (this->
next_ !=
nullptr) {
284 if (this->
next_ ==
nullptr)
307 for (
auto *action : actions) {
316 this->
play_tuple_(tuple, std::make_index_sequence<
sizeof...(Ts)>{});
338 template<
size_t... S>
void play_tuple_(
const std::tuple<Ts...> &tuple, std::index_sequence<S...> ) {
339 this->
play(std::get<S>(tuple)...);
virtual bool is_running()
Check if this or any of the following actions are currently running.
void play_next_(const Ts &...x)
virtual void stop_complex()
virtual void play(const Ts &...x)=0
void play_next_tuple_(const std::tuple< Ts... > &tuple)
int num_running_
The number of instances of this sequence in the list of actions that is currently being executed.
int num_running_total()
The total number of actions that are currently running in this plus any of the following actions in t...
void play_next_tuple_(const std::tuple< Ts... > &tuple, std::index_sequence< S... >)
virtual void play_complex(const Ts &...x)
void add_action(Action< Ts... > *action)
Action< Ts... > * actions_end_
void play(const Ts &...x)
void play_tuple(const std::tuple< Ts... > &tuple)
bool is_running()
Check if any action in this action list is currently running.
void add_actions(const std::initializer_list< Action< Ts... > * > &actions)
Action< Ts... > * actions_begin_
void play_tuple_(const std::tuple< Ts... > &tuple, std::index_sequence< S... >)
int num_running()
Return the number of actions in this action list that are currently running.
void add_action(Action< Ts... > *action)
void trigger(const Ts &...x)
Trigger< Ts... > * trigger_
int num_running()
Return the number of actions in the action part of this automation that are currently running.
Automation(Trigger< Ts... > *trigger)
void add_actions(const std::initializer_list< Action< Ts... > * > &actions)
ActionList< Ts... > actions_
Base class for all automation conditions.
bool check_tuple_(const std::tuple< Ts... > &tuple, std::index_sequence< S... >)
bool check_tuple(const std::tuple< Ts... > &tuple)
Call check with a tuple of values as parameter.
virtual bool check(const Ts &...x)=0
Check whether this condition passes. This condition check must be instant, and not cause any delays.
Simple continuation action that calls play_next_ on a parent action.
TemplatableValue(const TemplatableValue &other)
TemplatableValue(F value)
std::function< T(X...)> * f_
TemplatableValue(const char *str)
TemplatableValue & operator=(TemplatableValue &&other) noexcept
enum esphome::TemplatableValue::@170 type_
TemplatableValue(TemplatableValue &&other) noexcept
TemplatableValue & operator=(const TemplatableValue &other)
T value_or(X... x, T default_value)
optional< T > optional_value(X... x)
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
Automation< Ts... > * automation_parent_
void stop_action()
Stop any action connected to this trigger.
bool is_action_running()
Returns true if any action connected to this trigger is running.
void set_automation_parent(Automation< Ts... > *automation_parent)
Providing packet encoding functions for exchanging data with a remote host.
struct ESPDEPRECATED("Use std::index_sequence instead. Removed in 2026.6.0", "2025.12.0") seq