mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Allow transforms and flashes to not update remote_values (#2313)
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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<LightFlashTransformer>(*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) { | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user