[script] Fix script.wait hanging when triggered from on_boot (#12102)

This commit is contained in:
J. Nick Koston authored and Jonathan Swoboda committed 2025-11-27 17:23:27 -05:00
1 parent acdcd56395
commit 278f12fb99
3 files changed
+190 -1

No files matched your search

+6 -1
View File
@@ -278,7 +278,12 @@ template<class C, typename... Ts> class ScriptWaitAction : public Action<Ts...>,
void setup() override {
// Start with loop disabled - only enable when there's work to do
this->disable_loop();
// IMPORTANT: Only disable if num_running_ is 0, otherwise play_complex() was already
// called before our setup() (e.g., from on_boot trigger at same priority level)
// and we must not undo its enable_loop() call
if (this->num_running_ == 0) {
this->disable_loop();
}
}
void play_complex(const Ts &...x) override {