diff --git a/esphome/components/light/light_call.cpp b/esphome/components/light/light_call.cpp index 178a78a94c..dc1e7d39fb 100644 --- a/esphome/components/light/light_call.cpp +++ b/esphome/components/light/light_call.cpp @@ -77,7 +77,7 @@ void LightCall::perform() { ESP_LOGD(TAG, " Flash length: %.1fs", *this->flash_length_ / 1e3f); } - this->parent_->start_flash_(v, *this->flash_length_); + this->parent_->start_flash_(v, *this->flash_length_, this->publish_); } else if (this->has_transition_()) { // TRANSITION if (this->publish_) { @@ -92,7 +92,7 @@ void LightCall::perform() { this->parent_->stop_effect_(); } - this->parent_->start_transition_(v, *this->transition_length_); + this->parent_->start_transition_(v, *this->transition_length_, this->publish_); } else if (this->has_effect_()) { // EFFECT diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index 945d3910d5..d7f539a8d8 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -228,13 +228,16 @@ void LightState::stop_effect_() { this->active_effect_index_ = 0; } -void LightState::start_transition_(const LightColorValues &target, uint32_t length) { +void LightState::start_transition_(const LightColorValues &target, uint32_t length, bool set_remote_values) { this->transformer_ = this->output_->create_default_transition(); this->transformer_->setup(this->current_values, target, length); - this->remote_values = target; + + if (set_remote_values) { + this->remote_values = target; + } } -void LightState::start_flash_(const LightColorValues &target, uint32_t length) { +void LightState::start_flash_(const LightColorValues &target, uint32_t length, bool set_remote_values) { LightColorValues end_colors = this->remote_values; // If starting a flash if one is already happening, set end values to end values of current flash // Hacky but works @@ -243,7 +246,10 @@ void LightState::start_flash_(const LightColorValues &target, uint32_t length) { this->transformer_ = make_unique(*this); this->transformer_->setup(end_colors, target, length); - this->remote_values = target; + + if (set_remote_values) { + this->remote_values = target; + }; } void LightState::set_immediately_(const LightColorValues &target, bool set_remote_values) { diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index dd42aa76db..f73a4c3b17 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -154,10 +154,10 @@ class LightState : public Nameable, public Component { /// Internal method to stop the current effect (if one is active). void stop_effect_(); /// Internal method to start a transition to the target color with the given length. - void start_transition_(const LightColorValues &target, uint32_t length); + void start_transition_(const LightColorValues &target, uint32_t length, bool set_remote_values); /// Internal method to start a flash for the specified amount of time. - void start_flash_(const LightColorValues &target, uint32_t length); + void start_flash_(const LightColorValues &target, uint32_t length, bool set_remote_values); /// Internal method to set the color values to target immediately (with no transition). void set_immediately_(const LightColorValues &target, bool set_remote_values);