mirror of
https://github.com/esphome/esphome.git
synced 2025-10-25 13:13:48 +01:00
Merge branch 'automations_init' into integration
This commit is contained in:
@@ -243,7 +243,7 @@ template<typename... Ts> class ActionList {
|
|||||||
}
|
}
|
||||||
this->actions_end_ = action;
|
this->actions_end_ = action;
|
||||||
}
|
}
|
||||||
void add_actions(const std::vector<Action<Ts...> *> &actions) {
|
void add_actions(const std::initializer_list<Action<Ts...> *> &actions) {
|
||||||
for (auto *action : actions) {
|
for (auto *action : actions) {
|
||||||
this->add_action(action);
|
this->add_action(action);
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ template<typename... Ts> class Automation {
|
|||||||
explicit Automation(Trigger<Ts...> *trigger) : trigger_(trigger) { this->trigger_->set_automation_parent(this); }
|
explicit Automation(Trigger<Ts...> *trigger) : trigger_(trigger) { this->trigger_->set_automation_parent(this); }
|
||||||
|
|
||||||
void add_action(Action<Ts...> *action) { this->actions_.add_action(action); }
|
void add_action(Action<Ts...> *action) { this->actions_.add_action(action); }
|
||||||
void add_actions(const std::vector<Action<Ts...> *> &actions) { this->actions_.add_actions(actions); }
|
void add_actions(const std::initializer_list<Action<Ts...> *> &actions) { this->actions_.add_actions(actions); }
|
||||||
|
|
||||||
void stop() { this->actions_.stop(); }
|
void stop() { this->actions_.stop(); }
|
||||||
|
|
||||||
|
|||||||
@@ -194,12 +194,12 @@ template<typename... Ts> class IfAction : public Action<Ts...> {
|
|||||||
public:
|
public:
|
||||||
explicit IfAction(Condition<Ts...> *condition) : condition_(condition) {}
|
explicit IfAction(Condition<Ts...> *condition) : condition_(condition) {}
|
||||||
|
|
||||||
void add_then(const std::vector<Action<Ts...> *> &actions) {
|
void add_then(const std::initializer_list<Action<Ts...> *> &actions) {
|
||||||
this->then_.add_actions(actions);
|
this->then_.add_actions(actions);
|
||||||
this->then_.add_action(new LambdaAction<Ts...>([this](Ts... x) { this->play_next_(x...); }));
|
this->then_.add_action(new LambdaAction<Ts...>([this](Ts... x) { this->play_next_(x...); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_else(const std::vector<Action<Ts...> *> &actions) {
|
void add_else(const std::initializer_list<Action<Ts...> *> &actions) {
|
||||||
this->else_.add_actions(actions);
|
this->else_.add_actions(actions);
|
||||||
this->else_.add_action(new LambdaAction<Ts...>([this](Ts... x) { this->play_next_(x...); }));
|
this->else_.add_action(new LambdaAction<Ts...>([this](Ts... x) { this->play_next_(x...); }));
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ template<typename... Ts> class WhileAction : public Action<Ts...> {
|
|||||||
public:
|
public:
|
||||||
WhileAction(Condition<Ts...> *condition) : condition_(condition) {}
|
WhileAction(Condition<Ts...> *condition) : condition_(condition) {}
|
||||||
|
|
||||||
void add_then(const std::vector<Action<Ts...> *> &actions) {
|
void add_then(const std::initializer_list<Action<Ts...> *> &actions) {
|
||||||
this->then_.add_actions(actions);
|
this->then_.add_actions(actions);
|
||||||
this->then_.add_action(new LambdaAction<Ts...>([this](Ts... x) {
|
this->then_.add_action(new LambdaAction<Ts...>([this](Ts... x) {
|
||||||
if (this->num_running_ > 0 && this->condition_->check_tuple(this->var_)) {
|
if (this->num_running_ > 0 && this->condition_->check_tuple(this->var_)) {
|
||||||
@@ -287,7 +287,7 @@ template<typename... Ts> class RepeatAction : public Action<Ts...> {
|
|||||||
public:
|
public:
|
||||||
TEMPLATABLE_VALUE(uint32_t, count)
|
TEMPLATABLE_VALUE(uint32_t, count)
|
||||||
|
|
||||||
void add_then(const std::vector<Action<uint32_t, Ts...> *> &actions) {
|
void add_then(const std::initializer_list<Action<uint32_t, Ts...> *> &actions) {
|
||||||
this->then_.add_actions(actions);
|
this->then_.add_actions(actions);
|
||||||
this->then_.add_action(new LambdaAction<uint32_t, Ts...>([this](uint32_t iteration, Ts... x) {
|
this->then_.add_action(new LambdaAction<uint32_t, Ts...>([this](uint32_t iteration, Ts... x) {
|
||||||
iteration++;
|
iteration++;
|
||||||
|
|||||||
Reference in New Issue
Block a user