mirror of
https://github.com/esphome/esphome.git
synced 2025-09-10 23:32:23 +01:00
Light transition fixes (#2320)
This commit is contained in:
@@ -12,12 +12,18 @@ namespace light {
|
||||
class LightTransitionTransformer : public LightTransformer {
|
||||
public:
|
||||
void start() override {
|
||||
// When turning light on from off state, use colors from target state.
|
||||
// When turning light on from off state, use target state and only increase brightness from zero.
|
||||
if (!this->start_values_.is_on() && this->target_values_.is_on()) {
|
||||
this->start_values_ = LightColorValues(this->target_values_);
|
||||
this->start_values_.set_brightness(0.0f);
|
||||
}
|
||||
|
||||
// When turning light off from on state, use source state and only decrease brightness to zero.
|
||||
if (this->start_values_.is_on() && !this->target_values_.is_on()) {
|
||||
this->target_values_ = LightColorValues(this->start_values_);
|
||||
this->target_values_.set_brightness(0.0f);
|
||||
}
|
||||
|
||||
// When changing color mode, go through off state, as color modes are orthogonal and there can't be two active.
|
||||
if (this->start_values_.get_color_mode() != this->target_values_.get_color_mode()) {
|
||||
this->changing_color_mode_ = true;
|
||||
|
Reference in New Issue
Block a user