1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-27 13:13:50 +00:00

Fix Light Trigger (#1308)

* make LightTransitionTransformer publish at end

* adjust on trigger + cleanup

* add target_state_reached_callback_

* fix format

* revert publish_at_end change

* fix bug for rapid on/off switching + remove debug logging

* formatting

* call state reached callback when no transition

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
This commit is contained in:
MartinWelsch
2020-10-11 03:50:53 +02:00
committed by GitHub
parent e35d56defe
commit 4988349677
3 changed files with 28 additions and 14 deletions

View File

@@ -145,6 +145,7 @@ void LightState::loop() {
if (this->transformer_ != nullptr) {
if (this->transformer_->is_finished()) {
this->remote_values = this->current_values = this->transformer_->get_end_values();
this->target_state_reached_callback_.call();
if (this->transformer_->publish_at_end())
this->publish_state();
this->transformer_ = nullptr;
@@ -336,6 +337,9 @@ void LightCall::perform() {
this->parent_->set_immediately_(v, this->publish_);
}
if (!this->has_transition_()) {
this->parent_->target_state_reached_callback_.call();
}
if (this->publish_) {
this->parent_->publish_state();
}
@@ -752,6 +756,10 @@ void LightState::current_values_as_cwww(float *cold_white, float *warm_white, bo
void LightState::add_new_remote_values_callback(std::function<void()> &&send_callback) {
this->remote_values_callback_.add(std::move(send_callback));
}
void LightState::add_new_target_state_reached_callback(std::function<void()> &&send_callback) {
this->target_state_reached_callback_.add(std::move(send_callback));
}
LightEffect *LightState::get_active_effect_() {
if (this->active_effect_index_ == 0)
return nullptr;