mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 12:06:26 +01:00
fix: color temperature change needs to be in the 0-1 range
This commit is contained in:
parent
801023c710
commit
d47b1af620
@ -307,13 +307,17 @@ LightColorValues LightCall::validate_() {
|
||||
|
||||
// Current and target values for different parameters
|
||||
float brightness_change = fabs(v.get_brightness() - this->parent_->current_values.get_brightness());
|
||||
float color_temp_change = fabs(v.get_color_temperature() - this->parent_->current_values.get_color_temperature());
|
||||
float color_temp_change =
|
||||
fabs((v.get_color_temperature() - this->parent_->current_values.get_color_temperature()) /
|
||||
(traits.get_max_mireds() - traits.get_min_mireds()));
|
||||
float red_change = fabs(v.get_red() - this->parent_->current_values.get_red());
|
||||
float green_change = fabs(v.get_green() - this->parent_->current_values.get_green());
|
||||
float blue_change = fabs(v.get_blue() - this->parent_->current_values.get_blue());
|
||||
|
||||
float cold_white_change = fabs(v.get_cold_white() - this->parent_->current_values.get_cold_white());
|
||||
float warm_white_change = fabs(v.get_warm_white() - this->parent_->current_values.get_warm_white());
|
||||
// Find the maximum change
|
||||
float change_ratio = std::max({brightness_change, color_temp_change, red_change, green_change, blue_change});
|
||||
float change_ratio = std::max({brightness_change, color_temp_change, red_change, green_change, blue_change,
|
||||
cold_white_change, warm_white_change});
|
||||
|
||||
// Calculate dynamic transition length based on state change
|
||||
this->transition_length_ = change_ratio * this->parent_->default_transition_length_;
|
||||
|
Loading…
Reference in New Issue
Block a user