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

Add "transformer_active" flag for use in effects. (#6157)

This commit is contained in:
Bill Adams
2024-02-06 15:13:55 -08:00
committed by GitHub
parent 05da0fb4cf
commit fe789c8beb
2 changed files with 19 additions and 0 deletions

View File

@@ -120,6 +120,7 @@ void LightState::loop() {
// Apply transformer (if any)
if (this->transformer_ != nullptr) {
auto values = this->transformer_->apply();
this->is_transformer_active_ = true;
if (values.has_value()) {
this->current_values = *values;
this->output_->update_state(this);
@@ -131,6 +132,7 @@ void LightState::loop() {
this->current_values = this->transformer_->get_target_values();
this->transformer_->stop();
this->is_transformer_active_ = false;
this->transformer_ = nullptr;
this->target_state_reached_callback_.call();
}
@@ -214,6 +216,8 @@ void LightState::current_values_as_ct(float *color_temperature, float *white_bri
this->gamma_correct_);
}
bool LightState::is_transformer_active() { return this->is_transformer_active_; }
void LightState::start_effect_(uint32_t effect_index) {
this->stop_effect_();
if (effect_index == 0)
@@ -263,6 +267,7 @@ void LightState::start_flash_(const LightColorValues &target, uint32_t length, b
}
void LightState::set_immediately_(const LightColorValues &target, bool set_remote_values) {
this->is_transformer_active_ = false;
this->transformer_ = nullptr;
this->current_values = target;
if (set_remote_values) {