Color mode implementation (#2012)

This commit is contained in:
Oxan van Leeuwen
2021-07-29 19:11:56 +02:00
committed by GitHub
parent de382b704c
commit 5983ccc55c
39 changed files with 1210 additions and 476 deletions
+6 -3
View File
@@ -45,11 +45,14 @@ void TuyaLight::dump_config() {
light::LightTraits TuyaLight::get_traits() {
auto traits = light::LightTraits();
traits.set_supports_brightness(this->dimmer_id_.has_value());
traits.set_supports_color_temperature(this->color_temperature_id_.has_value());
if (this->color_temperature_id_.has_value()) {
if (this->color_temperature_id_.has_value() && this->dimmer_id_.has_value()) {
traits.set_supported_color_modes({light::ColorMode::COLOR_TEMPERATURE});
traits.set_min_mireds(this->cold_white_temperature_);
traits.set_max_mireds(this->warm_white_temperature_);
} else if (this->dimmer_id_.has_value()) {
traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
} else {
traits.set_supported_color_modes({light::ColorMode::ON_OFF});
}
return traits;
}