mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 15:08:10 +01:00
Fix RGBW color-interlock control (#1325)
This commit is contained in:
parent
0c87a9ad2c
commit
c9caf44c2e
1 changed files with 13 additions and 11 deletions
|
@ -399,13 +399,13 @@ LightColorValues LightCall::validate_() {
|
||||||
|
|
||||||
// sets RGB to 100% if only White specified
|
// sets RGB to 100% if only White specified
|
||||||
if (this->white_.has_value()) {
|
if (this->white_.has_value()) {
|
||||||
|
if (traits.get_supports_color_interlock()) {
|
||||||
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
|
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
|
||||||
this->red_ = optional<float>(1.0f);
|
this->red_ = optional<float>(1.0f);
|
||||||
this->green_ = optional<float>(1.0f);
|
this->green_ = optional<float>(1.0f);
|
||||||
this->blue_ = optional<float>(1.0f);
|
this->blue_ = optional<float>(1.0f);
|
||||||
}
|
}
|
||||||
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
|
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
|
||||||
if (traits.get_supports_color_interlock()) {
|
|
||||||
if (*this->white_ > 0.0f) {
|
if (*this->white_ > 0.0f) {
|
||||||
this->white_ = optional<float>(1.0f);
|
this->white_ = optional<float>(1.0f);
|
||||||
} else {
|
} else {
|
||||||
|
@ -415,13 +415,15 @@ LightColorValues LightCall::validate_() {
|
||||||
}
|
}
|
||||||
// White to 0% if (exclusively) setting any RGB value that isn't 255,255,255
|
// White to 0% if (exclusively) setting any RGB value that isn't 255,255,255
|
||||||
else if (this->red_.has_value() || this->green_.has_value() || this->blue_.has_value()) {
|
else if (this->red_.has_value() || this->green_.has_value() || this->blue_.has_value()) {
|
||||||
if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f && traits.get_supports_rgb_white_value() &&
|
if (traits.get_supports_color_interlock()) {
|
||||||
traits.get_supports_color_interlock()) {
|
if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f &&
|
||||||
|
traits.get_supports_rgb_white_value() && traits.get_supports_color_interlock()) {
|
||||||
this->white_ = optional<float>(1.0f);
|
this->white_ = optional<float>(1.0f);
|
||||||
} else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) {
|
} else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) {
|
||||||
this->white_ = optional<float>(0.0f);
|
this->white_ = optional<float>(0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// if changing Kelvin alone, change to white light
|
// if changing Kelvin alone, change to white light
|
||||||
else if (this->color_temperature_.has_value()) {
|
else if (this->color_temperature_.has_value()) {
|
||||||
if (!traits.get_supports_color_interlock()) {
|
if (!traits.get_supports_color_interlock()) {
|
||||||
|
|
Loading…
Reference in a new issue