mirror of
https://github.com/esphome/esphome.git
synced 2025-11-20 00:35:44 +00:00
Addressable updates
This commit is contained in:
@@ -7,7 +7,16 @@ namespace script {
|
||||
|
||||
class Script : public Trigger<> {
|
||||
public:
|
||||
void execute() { this->trigger(); }
|
||||
void execute() {
|
||||
bool prev = this->in_stack_;
|
||||
this->in_stack_ = true;
|
||||
this->trigger();
|
||||
this->in_stack_ = prev;
|
||||
}
|
||||
bool script_is_running() { return this->in_stack_ || this->is_running(); }
|
||||
|
||||
protected:
|
||||
bool in_stack_{false};
|
||||
};
|
||||
|
||||
template<typename... Ts> class ScriptExecuteAction : public Action<Ts...> {
|
||||
@@ -30,5 +39,15 @@ template<typename... Ts> class ScriptStopAction : public Action<Ts...> {
|
||||
Script *script_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class IsRunningCondition : public Condition<Ts...> {
|
||||
public:
|
||||
explicit IsRunningCondition(Script *parent) : parent_(parent) {}
|
||||
|
||||
bool check(Ts... x) override { return this->parent_->script_is_running(); }
|
||||
|
||||
protected:
|
||||
Script *parent_;
|
||||
};
|
||||
|
||||
} // namespace script
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user