ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
base_automation.h
Go to the documentation of this file.
1#pragma once
2
5#include "esphome/core/hal.h"
11
12#include <array>
13#include <list>
14#include <tuple>
15#include <type_traits>
16#include <vector>
17
18namespace esphome {
19
20template<size_t N, typename... Ts> class AndCondition : public Condition<Ts...> {
21 public:
22 explicit AndCondition(std::initializer_list<Condition<Ts...> *> conditions) {
23 init_array_from(this->conditions_, conditions);
24 }
25 // Codegen passes each condition as its own argument; a list literal would sit in .rodata (RAM on ESP8266).
26 template<typename... Cs>
27 requires(sizeof...(Cs) == N)
28 explicit AndCondition(Cs *...conditions) : conditions_{conditions...} {}
29 bool check(const Ts &...x) override {
30 for (auto *condition : this->conditions_) {
31 if (!condition->check(x...))
32 return false;
33 }
34
35 return true;
36 }
37
38 protected:
39 std::array<Condition<Ts...> *, N> conditions_{};
40};
41
42template<size_t N, typename... Ts> class OrCondition : public Condition<Ts...> {
43 public:
44 explicit OrCondition(std::initializer_list<Condition<Ts...> *> conditions) {
45 init_array_from(this->conditions_, conditions);
46 }
47 // Codegen passes each condition as its own argument; a list literal would sit in .rodata (RAM on ESP8266).
48 template<typename... Cs>
49 requires(sizeof...(Cs) == N)
50 explicit OrCondition(Cs *...conditions) : conditions_{conditions...} {}
51 bool check(const Ts &...x) override {
52 for (auto *condition : this->conditions_) {
53 if (condition->check(x...))
54 return true;
55 }
56
57 return false;
58 }
59
60 protected:
61 std::array<Condition<Ts...> *, N> conditions_{};
62};
63
64template<typename... Ts> class NotCondition : public Condition<Ts...> {
65 public:
66 explicit NotCondition(Condition<Ts...> *condition) : condition_(condition) {}
67 bool check(const Ts &...x) override { return !this->condition_->check(x...); }
68
69 protected:
71};
72
73template<size_t N, typename... Ts> class XorCondition : public Condition<Ts...> {
74 public:
75 explicit XorCondition(std::initializer_list<Condition<Ts...> *> conditions) {
76 init_array_from(this->conditions_, conditions);
77 }
78 // Codegen passes each condition as its own argument; a list literal would sit in .rodata (RAM on ESP8266).
79 template<typename... Cs>
80 requires(sizeof...(Cs) == N)
81 explicit XorCondition(Cs *...conditions) : conditions_{conditions...} {}
82 bool check(const Ts &...x) override {
83 size_t result = 0;
84 for (auto *condition : this->conditions_) {
85 result += condition->check(x...);
86 }
87
88 return result == 1;
89 }
90
91 protected:
92 std::array<Condition<Ts...> *, N> conditions_{};
93};
94
95template<typename... Ts> class LambdaCondition : public Condition<Ts...> {
96 public:
97 explicit LambdaCondition(std::function<bool(Ts...)> &&f) : f_(std::move(f)) {}
98 bool check(const Ts &...x) override { return this->f_(x...); }
99
100 protected:
101 std::function<bool(Ts...)> f_;
102};
103
107template<typename... Ts> class StatelessLambdaCondition : public Condition<Ts...> {
108 public:
109 explicit StatelessLambdaCondition(bool (*f)(Ts...)) : f_(f) {}
110 bool check(const Ts &...x) override { return this->f_(x...); }
111
112 protected:
113 bool (*f_)(Ts...);
114};
115
116template<typename... Ts> class ForCondition : public Condition<Ts...>, public Component {
117 public:
118 explicit ForCondition(Condition<> *condition) : condition_(condition) {}
119
121
122 void loop() override {
123 // Safe to use cached time - only called from Application::loop()
125 }
126
127 float get_setup_priority() const override { return setup_priority::DATA; }
128
129 bool check(const Ts &...x) override {
130 auto now = millis();
131 if (!this->check_internal_(now))
132 return false;
133 return now - this->last_inactive_ >= this->time_.value(x...);
134 }
135
136 protected:
138 bool cond = this->condition_->check();
139 if (!cond)
140 this->last_inactive_ = now;
141 return cond;
142 }
143
146};
147
148class StartupTrigger : public Trigger<>, public Component {
149 public:
150 explicit StartupTrigger(float setup_priority) : setup_priority_(setup_priority) {}
151 void setup() override { this->trigger(); }
152 float get_setup_priority() const override { return this->setup_priority_; }
153
154 protected:
156};
157
158class ShutdownTrigger : public Trigger<>, public Component {
159 public:
160 explicit ShutdownTrigger(float setup_priority) : setup_priority_(setup_priority) {}
161 void on_shutdown() override { this->trigger(); }
162 float get_setup_priority() const override { return this->setup_priority_; }
163
164 protected:
166};
167
168class LoopTrigger : public Trigger<>, public Component {
169 public:
170 void loop() override { this->trigger(); }
171 float get_setup_priority() const override { return setup_priority::DATA; }
172};
173
174#ifdef ESPHOME_PROJECT_NAME
175class ProjectUpdateTrigger : public Trigger<std::string>, public Component {
176 public:
177 void setup() override {
178 uint32_t hash = fnv1_hash(ESPHOME_PROJECT_NAME);
179 ESPPreferenceObject pref = global_preferences->make_preference<char[30]>(hash, true);
180 char previous_version[30];
181 char current_version[30] = ESPHOME_PROJECT_VERSION_30;
182 if (pref.load(&previous_version)) {
183 int cmp = strcmp(previous_version, current_version);
184 if (cmp < 0) {
185 this->trigger(previous_version);
186 }
187 }
188 pref.save(&current_version);
190 }
191 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
192};
193#endif
194
195template<typename... Ts> class DelayAction : public Action<Ts...> {
196 public:
197 // User provided, not "= default": `new(p) DelayAction()` would zero-fill .bss that is already zero.
198 // constexpr and noexcept keep the rest of the implicit constructor's contract.
199 constexpr explicit DelayAction() noexcept {}
200
202
203 void play_complex(const Ts &...x) override {
204 this->num_running_++;
205
206 // If num_running_ > 1, we have multiple instances running in parallel
207 // In single/restart/queued modes, only one instance runs at a time
208 // Parallel mode uses skip_cancel=true to allow multiple delays to coexist
209 // WARNING: This can accumulate delays if scripts are triggered faster than they complete!
210 // Users should set max_runs on parallel scripts to limit concurrent executions.
211 // Issue #10264: This is a workaround for parallel script delays interfering with each other.
212
213 // Optimization: For no-argument delays (most common case), use direct lambda
214 // to avoid overhead from capturing arguments by value
215 if constexpr (sizeof...(Ts) == 0) {
216 auto f = [this]() { this->play_next_(); };
217 App.scheduler.set_timer_common_(
218 /* component= */ nullptr, Scheduler::SchedulerItem::TIMEOUT, Scheduler::NameType::SELF_POINTER,
219 /* static_name= */ reinterpret_cast<const char *>(this), /* hash_or_id= */ 0, this->delay_.value(),
220 std::move(f),
221 /* skip_cancel= */ this->num_running_ > 1,
222 // Record the owning script (if any) so the blocking warning can name it; propagates across
223 // chained delays via the scheduler.
224 /* source= */ App.get_current_source());
225 } else {
226 // For delays with arguments, capture by value to preserve argument values
227 // Arguments must be copied because original references may be invalid after delay
228 // `mutable` is required so captured copies of non-const reference args (e.g. std::string&)
229 // are passed as non-const lvalues to play_next_(const Ts&...) where Ts may be `T&`
230 auto f = [this, x...]() mutable { this->play_next_(x...); };
231 App.scheduler.set_timer_common_(
232 /* component= */ nullptr, Scheduler::SchedulerItem::TIMEOUT, Scheduler::NameType::SELF_POINTER,
233 /* static_name= */ reinterpret_cast<const char *>(this), /* hash_or_id= */ 0, this->delay_.value(x...),
234 std::move(f),
235 /* skip_cancel= */ this->num_running_ > 1,
236 // See the no-argument branch above: record the owning script for log attribution.
237 /* source= */ App.get_current_source());
238 }
239 }
240
241 void play(const Ts &...x) override { /* ignore - see play_complex */ }
242
243 void stop() override { App.scheduler.cancel_timeout(this); }
244};
245
246template<typename... Ts> class LambdaAction : public Action<Ts...> {
247 public:
248 explicit LambdaAction(std::function<void(Ts...)> &&f) : f_(std::move(f)) {}
249
250 void play(const Ts &...x) override { this->f_(x...); }
251
252 protected:
253 std::function<void(Ts...)> f_;
254};
255
259template<typename... Ts> class StatelessLambdaAction : public Action<Ts...> {
260 public:
261 explicit StatelessLambdaAction(void (*f)(Ts...)) : f_(f) {}
262
263 void play(const Ts &...x) override { this->f_(x...); }
264
265 protected:
266 void (*f_)(Ts...);
267};
268
273template<auto Fn, typename... Ts> class ApplyAction final : public Action<Ts...> {
274 public:
275 void play(const Ts &...x) override { Fn(x...); }
276};
277
280template<auto Fn, typename... Ts> class ApplyRunAction final : public Action<Ts...> {
281 public:
282 void play(const Ts &...x) override {
283 // Any other type would bind the function's const int & to a temporary that never sees a stop
284 static_assert(std::is_same_v<decltype(this->num_running_), int>);
285 Fn(this->num_running_, x...);
286 }
287};
288
290template<auto Fn, typename... Ts> class ApplyCondition final : public Condition<Ts...> {
291 public:
292 bool check(const Ts &...x) override { return Fn(x...); }
293};
294
295template<bool HasElse, typename... Ts> class IfAction : public Action<Ts...> {
296 public:
297 explicit IfAction(Condition<Ts...> *condition) : condition_(condition) {}
298
299 // Precondition: build each branch either with one add_then/add_else call, or with
300 // add_then_action/add_else_action calls followed by one finish_then/finish_else, never both.
301 // set_owner() closes the list; appending after it is a codegen bug.
302 void add_then(const std::initializer_list<Action<Ts...> *> &actions) {
303 this->then_.add_actions(actions);
304 this->then_.set_owner(this);
305 }
306
307 void add_else(const std::initializer_list<Action<Ts...> *> &actions)
308 requires(HasElse)
309 {
310 this->else_.add_actions(actions);
311 this->else_.set_owner(this);
312 }
313
314 // Codegen appends branch actions one at a time, then finishes each branch once; a list literal
315 // would be a constant array in .rodata, which is RAM on ESP8266.
316 void add_then_action(Action<Ts...> *action) { this->then_.add_action(action); }
317 void finish_then() { this->then_.set_owner(this); }
319 requires(HasElse)
320 {
321 this->else_.add_action(action);
322 }
324 requires(HasElse)
325 {
326 this->else_.set_owner(this);
327 }
328
329 void play_complex(const Ts &...x) final {
330 this->num_running_++;
331 // The condition may stop this automation (e.g. script.stop in a lambda)
332 if (this->condition_->check(x...)) {
333 if (!this->then_.empty() && this->num_running_ > 0) {
334 this->then_.play(x...);
335 return;
336 }
337 } else if constexpr (HasElse) {
338 if (!this->else_.empty() && this->num_running_ > 0) {
339 this->else_.play(x...);
340 return;
341 }
342 }
343 this->play_next_(x...);
344 }
345
346 // Branch-end resume hook
347 void play(const Ts &...x) override { this->play_next_(x...); }
348
349 void stop() override {
350 this->then_.stop();
351 if constexpr (HasElse) {
352 this->else_.stop();
353 }
354 }
355
356 protected:
359 struct NoElse {};
360 [[no_unique_address]] std::conditional_t<HasElse, ActionList<Ts...>, NoElse> else_;
361};
362
363template<typename... Ts> class WhileAction : public Action<Ts...> {
364 public:
365 WhileAction(Condition<Ts...> *condition) : condition_(condition) {}
366
367 // Precondition: use either add_then or add_then_action plus one finish_then, never both
368 // (see IfAction::add_then).
369 void add_then(const std::initializer_list<Action<Ts...> *> &actions) {
370 this->then_.add_actions(actions);
371 this->then_.set_owner(this);
372 }
373 void add_then_action(Action<Ts...> *action) { this->then_.add_action(action); }
374 void finish_then() { this->then_.set_owner(this); }
375
376 void play_complex(const Ts &...x) final {
377 this->num_running_++;
378 // Initial condition check
379 if (!this->condition_->check(x...)) {
380 // If new condition check failed, stop loop if running
381 this->then_.stop();
382 this->play_next_(x...);
383 return;
384 }
385
386 // The condition may have stopped this automation
387 if (this->num_running_ == 0)
388 return;
389 // An empty body cannot resume the loop
390 if (this->then_.empty()) {
391 this->play_next_(x...);
392 return;
393 }
394 this->then_.play(x...);
395 }
396
397 // Branch-end resume hook: loop again or continue
398 void play(const Ts &...x) override {
399 // The condition may stop this automation
400 if (this->num_running_ > 0 && this->condition_->check(x...) && this->num_running_ > 0) {
401 this->then_.play(x...);
402 } else {
403 this->play_next_(x...);
404 }
405 }
406
407 void stop() override { this->then_.stop(); }
408
409 protected:
412};
413
414// Forward declaration for RepeatLoopContinuation
415template<typename... Ts> class RepeatAction;
416
419template<typename... Ts> class RepeatLoopContinuation : public Action<uint32_t, Ts...> {
420 public:
422
423 void play(const uint32_t &iteration, const Ts &...x) override;
424
425 protected:
427};
428
429template<typename... Ts> class RepeatAction : public Action<Ts...> {
430 public:
432
433 // Precondition: use either add_then or add_then_action plus one finish_then, never both
434 // (see IfAction::add_then); appending the continuation twice forms a self-loop.
435 void add_then(const std::initializer_list<Action<uint32_t, Ts...> *> &actions) {
436 this->then_.add_actions(actions);
437 this->then_.add_action(&this->loop_continuation_);
438 }
441
442 friend class RepeatLoopContinuation<Ts...>;
443
444 void play_complex(const Ts &...x) override {
445 this->num_running_++;
446 if (this->count_.value(x...) > 0) {
447 this->then_.play(0, x...);
448 } else {
449 this->play_next_(x...);
450 }
451 }
452
453 void play(const Ts &...x) override { /* ignore - see play_complex */ }
454
455 void stop() override { this->then_.stop(); }
456
457 protected:
460};
461
462// Implementation of RepeatLoopContinuation::play
463template<typename... Ts> void RepeatLoopContinuation<Ts...>::play(const uint32_t &iteration, const Ts &...x) {
464 uint32_t next_iteration = iteration + 1;
465 if (next_iteration >= this->parent_->count_.value(x...)) {
466 this->parent_->play_next_(x...);
467 } else {
468 this->parent_->then_.play(next_iteration, x...);
469 }
470}
471
479template<typename... Ts> class WaitUntilAction : public Action<Ts...>, public Component {
480 public:
481 WaitUntilAction(Condition<Ts...> *condition) : condition_(condition) {}
482
484
485 void setup() override {
486 // Start with loop disabled - only enable when there's work to do
487 // IMPORTANT: Only disable if num_running_ is 0, otherwise play_complex() was already
488 // called before our setup() (e.g., from on_boot trigger at same priority level)
489 // and we must not undo its enable_loop() call
490 if (this->num_running_ == 0) {
491 this->disable_loop();
492 }
493 }
494
495 void play_complex(const Ts &...x) override {
496 this->num_running_++;
497 // Check if we can continue immediately.
498 if (this->condition_->check(x...)) {
499 if (this->num_running_ > 0) {
500 this->play_next_(x...);
501 }
502 return;
503 }
504
505 // Store for later processing
506 auto now = millis();
507 auto timeout = this->timeout_value_.optional_value(x...);
508 this->var_queue_.emplace_back(now, timeout, x...);
509
510 // Do immediate check with fresh timestamp - don't call loop() synchronously!
511 // Let the event loop call it to avoid reentrancy issues
512 if (this->process_queue_(now)) {
513 // Only enable loop if we still have pending items
514 this->enable_loop();
515 }
516 }
517
518 void loop() override {
519 // Safe to use cached time - only called from Application::loop()
521 // If queue is now empty, disable loop until next play_complex
522 this->disable_loop();
523 }
524 }
525
526 void stop() override {
527 this->var_queue_.clear();
528 // Tell any process_queue_() call further down the stack that the items it is
529 // still holding were cancelled
530 this->stop_generation_++;
531 this->disable_loop();
532 }
533
534 float get_setup_priority() const override { return setup_priority::DATA; }
535
536 void play(const Ts &...x) override { /* ignore - see play_complex */ }
537
538 protected:
539 struct QueueItem {
540 QueueItem(uint32_t start, optional<uint32_t> timeout, const Ts &...x)
541 : start(start), timeout(timeout), args(x...) {}
543 optional<uint32_t> timeout;
544 std::tuple<stored_trigger_arg_t<Ts>...> args;
545 };
546
547 // Helper: Process queue, triggering completed items and removing them
548 // Returns true if queue still has pending items
550 // Completed items run the rest of the action chain synchronously, and that chain
551 // can re-enter this same action (e.g. a script with mode: restart that executes
552 // itself) and add to or clear var_queue_. Iterating the member list directly would
553 // then corrupt it, so move it aside and iterate a local list instead.
554 std::list<QueueItem> queue;
555 queue.swap(this->var_queue_);
556 std::list<QueueItem> pending;
557 while (!queue.empty()) {
558 auto it = queue.begin();
559 auto start = it->start;
560 auto timeout = it->timeout;
561
562 // Check if timeout has expired
563 auto expired = timeout && (now - start) >= *timeout;
564
565 // Keep waiting if not expired and condition not met
566 if (!expired && !std::apply([this](auto &...args) { return this->condition_->check(args...); }, it->args)) {
567 pending.splice(pending.end(), queue, it);
568 continue;
569 }
570
571 // Condition met or timed out - trigger the next action. Keep the item in a local
572 // holder so its arguments stay valid while the chain runs, without any nested
573 // process_queue_() call being able to see (and fire) it again.
574 std::list<QueueItem> completed;
575 completed.splice(completed.begin(), queue, it);
576 uint8_t generation = this->stop_generation_;
577 std::apply([this](auto &...args) { this->play_next_(args...); }, completed.front().args);
578 if (generation != this->stop_generation_) {
579 // stop() ran inside the chain - the items still held locally were cancelled
580 pending.clear();
581 break;
582 }
583 }
584
585 // Re-entrant continuations may have enqueued new waits into var_queue_; put the
586 // older still-waiting items back in front of them to keep FIFO firing order
587 this->var_queue_.splice(this->var_queue_.begin(), pending);
588
589 return !this->var_queue_.empty();
590 }
591
593 std::list<QueueItem> var_queue_{};
594 // Bumped by stop() so process_queue_() can detect a stop from inside play_next_()
596};
597
598template<typename... Ts> class UpdateComponentAction : public Action<Ts...> {
599 public:
601
602 void play(const Ts &...x) override {
603 if (!this->component_->is_ready())
604 return;
605 this->component_->update();
606 }
607
608 protected:
610};
611
612template<typename... Ts> class SuspendComponentAction : public Action<Ts...> {
613 public:
615
616 void play(const Ts &...x) override {
617 if (!this->component_->is_ready())
618 return;
619 this->component_->stop_poller();
620 }
621
622 protected:
624};
625
626template<typename... Ts> class ResumeComponentAction : public Action<Ts...> {
627 public:
629 TEMPLATABLE_VALUE(uint32_t, update_interval)
630
631 void play(const Ts &...x) override {
632 if (!this->component_->is_ready()) {
633 return;
634 }
635 optional<uint32_t> update_interval = this->update_interval_.optional_value(x...);
636 if (update_interval.has_value()) {
637 this->component_->set_update_interval(update_interval.value());
638 }
639 this->component_->start_poller();
640 }
641
642 protected:
644};
645
646} // namespace esphome
void play_next_(const Ts &...x)
Definition automation.h:614
virtual void play(const Ts &...x)=0
virtual void play_complex(const Ts &...x)
Definition automation.h:585
void add_action(Action< Ts... > *action)
Definition automation.h:665
bool empty() const
Definition automation.h:697
void add_actions(const std::initializer_list< Action< Ts... > * > &actions)
Definition automation.h:669
void play(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:686
void set_owner(Action< Ts... > *owner)
Resume owner via play() when the list finishes; call once, after adding actions.
Definition automation.h:678
AndCondition(std::initializer_list< Condition< Ts... > * > conditions)
bool check(const Ts &...x) override
std::array< Condition< Ts... > *, N > conditions_
AndCondition(Cs *...conditions)
const LogString * get_current_source()
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
Runs one codegen-generated function that has the parent and every field baked in.
void play(const Ts &...x) override
Condition counterpart of ApplyAction: one codegen-generated predicate with the parent baked in.
bool check(const Ts &...x) override
Runs several adjacent actions merged by codegen into one generated function.
void play(const Ts &...x) override
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
bool is_ready() const
void enable_loop()
Enable this component's loop.
Definition component.h:261
void disable_loop()
Disable this component's loop.
Base class for all automation conditions.
Definition automation.h:534
virtual bool check(const Ts &...x)=0
Check whether this condition passes. This condition check must be instant, and not cause any delays.
void play(const Ts &...x) override
TEMPLATABLE_VALUE(uint32_t, delay) void play_complex(const Ts &...x) override
constexpr DelayAction() noexcept
bool check_internal_(uint32_t now)
ForCondition(Condition<> *condition)
float get_setup_priority() const override
bool check(const Ts &...x) override
TEMPLATABLE_VALUE(uint32_t, time)
ActionList< Ts... > then_
Condition< Ts... > * condition_
void play(const Ts &...x) override
void add_then(const std::initializer_list< Action< Ts... > * > &actions)
void stop() override
void play_complex(const Ts &...x) final
std::conditional_t< HasElse, ActionList< Ts... >, NoElse > else_
void add_else_action(Action< Ts... > *action)
void add_then_action(Action< Ts... > *action)
IfAction(Condition< Ts... > *condition)
void add_else(const std::initializer_list< Action< Ts... > * > &actions)
LambdaAction(std::function< void(Ts...)> &&f)
void play(const Ts &...x) override
std::function< void(Ts...)> f_
bool check(const Ts &...x) override
LambdaCondition(std::function< bool(Ts...)> &&f)
std::function< bool(Ts...)> f_
float get_setup_priority() const override
Condition< Ts... > * condition_
bool check(const Ts &...x) override
NotCondition(Condition< Ts... > *condition)
OrCondition(std::initializer_list< Condition< Ts... > * > conditions)
OrCondition(Cs *...conditions)
bool check(const Ts &...x) override
std::array< Condition< Ts... > *, N > conditions_
This class simplifies creating components that periodically check a state.
Definition component.h:532
void set_update_interval(uint32_t update_interval)
Manually set the update interval in ms for this polling object.
Definition component.h:546
virtual void update()=0
float get_setup_priority() const override
ActionList< uint32_t, Ts... > then_
TEMPLATABLE_VALUE(uint32_t, count) void add_then(const std
void add_then_action(Action< uint32_t, Ts... > *action)
void play_complex(const Ts &...x) override
void play(const Ts &...x) override
RepeatLoopContinuation< Ts... > loop_continuation_
Loop continuation for RepeatAction that increments iteration and repeats or continues.
RepeatLoopContinuation(RepeatAction< Ts... > *parent)
RepeatAction< Ts... > * parent_
void play(const uint32_t &iteration, const Ts &...x) override
ResumeComponentAction(PollingComponent *component)
TEMPLATABLE_VALUE(uint32_t, update_interval) void play(const Ts &...x) override
ShutdownTrigger(float setup_priority)
float get_setup_priority() const override
float get_setup_priority() const override
StartupTrigger(float setup_priority)
Optimized lambda action for stateless lambdas (no capture).
void play(const Ts &...x) override
Optimized lambda condition for stateless lambdas (no capture).
bool check(const Ts &...x) override
SuspendComponentAction(PollingComponent *component)
void play(const Ts &...x) override
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:557
void play(const Ts &...x) override
UpdateComponentAction(PollingComponent *component)
Wait until a condition is true to continue execution.
WaitUntilAction(Condition< Ts... > *condition)
std::list< QueueItem > var_queue_
TEMPLATABLE_VALUE(uint32_t, timeout_value) void setup() override
void play_complex(const Ts &...x) override
void play(const Ts &...x) override
bool process_queue_(uint32_t now)
Condition< Ts... > * condition_
float get_setup_priority() const override
void add_then(const std::initializer_list< Action< Ts... > * > &actions)
void play_complex(const Ts &...x) final
WhileAction(Condition< Ts... > *condition)
void play(const Ts &...x) override
void add_then_action(Action< Ts... > *action)
Condition< Ts... > * condition_
ActionList< Ts... > then_
std::array< Condition< Ts... > *, N > conditions_
XorCondition(Cs *...conditions)
bool check(const Ts &...x) override
XorCondition(std::initializer_list< Condition< Ts... > * > conditions)
const Component * component
Definition component.cpp:34
unsigned count
Definition gif.cpp:51
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition component.h:45
constexpr float PROCESSOR
For components that use data from sensors like displays.
Definition component.h:47
ESPPreferences * global_preferences
uint32_t fnv1_hash(const char *str)
Calculate a FNV-1 hash of str.
Definition helpers.cpp:169
void init_array_from(std::array< T, N > &dest, std::initializer_list< T > src)
Initialize a std::array from an initializer_list.
Definition helpers.h:644
void HOT delay(uint32_t ms)
Definition hal.cpp:85
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:25
Application App
Global storage of Application pointer - only one Application can exist.
STL namespace.
static void uint32_t
ESPPreferenceObject make_preference(size_t, uint32_t, bool)
Definition preferences.h:24
bool sync()
Commit pending writes to flash.
Definition preferences.h:33
std::tuple< stored_trigger_arg_t< Ts >... > args
QueueItem(uint32_t start, optional< uint32_t > timeout, const Ts &...x)
uint16_t x
Definition tt21100.cpp:5