From aae633277fc906018bcdbd0cec006b903009b497 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 17 Oct 2019 19:15:02 +0200 Subject: [PATCH] Fix strobe/flicker effect not using selected value (#749) Fixes https://github.com/esphome/issues/issues/562 --- esphome/components/light/light_state.cpp | 11 +++++++---- esphome/components/light/light_state.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index cafced27fc..2b16319ddb 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -24,9 +24,12 @@ void LightState::start_flash_(const LightColorValues &target, uint32_t length) { LightState::LightState(const std::string &name, LightOutput *output) : Nameable(name), output_(output) {} -void LightState::set_immediately_(const LightColorValues &target) { +void LightState::set_immediately_(const LightColorValues &target, bool set_remote_values) { this->transformer_ = nullptr; - this->current_values = this->remote_values = target; + this->current_values = target; + if (set_remote_values) { + this->remote_values = target; + } this->next_write_ = true; } @@ -327,10 +330,10 @@ void LightCall::perform() { // Also set light color values when starting an effect // For example to turn off the light - this->parent_->set_immediately_(v); + this->parent_->set_immediately_(v, true); } else { // INSTANT CHANGE - this->parent_->set_immediately_(v); + this->parent_->set_immediately_(v, this->publish_); } if (this->publish_) { diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index d67aa2c53d..c460be09be 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -291,7 +291,7 @@ class LightState : public Nameable, public Component { void start_flash_(const LightColorValues &target, uint32_t length); /// Internal method to set the color values to target immediately (with no transition). - void set_immediately_(const LightColorValues &target); + void set_immediately_(const LightColorValues &target, bool set_remote_values); /// Internal method to start a transformer. void set_transformer_(std::unique_ptr transformer);