From 9b458d25ea143636ab3c1c7c04b75adf31b0d2d8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Nov 2025 21:20:11 -0600 Subject: [PATCH] light loop --- esphome/components/light/light_state.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index 4d39ac9983f..f3b8347507e 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -139,6 +139,8 @@ void LightState::loop() { if (this->next_write_) { this->next_write_ = false; this->output_->write_state(this); + // Disable loop if idle (no transformer and no effect) + this->disable_loop_if_idle_(); } } @@ -291,13 +293,12 @@ void LightState::set_immediately_(const LightColorValues &target, bool set_remot } this->output_->update_state(this); this->next_write_ = true; - // Disable loop if idle (no transformer and no effect) - this->disable_loop_if_idle_(); + this->enable_loop(); } void LightState::disable_loop_if_idle_() { - // Only disable loop if both transformer and effect are inactive - if (this->transformer_ == nullptr && this->get_active_effect_() == nullptr) { + // Only disable loop if both transformer and effect are inactive, and no pending writes + if (this->transformer_ == nullptr && this->get_active_effect_() == nullptr && !this->next_write_) { this->disable_loop(); } }