tuya_light: fix float->int conversion while setting color temperature (#5067)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: kswt <kswt@xmpp.is>
This commit is contained in:
kswt 2023-07-12 04:28:48 +03:00 committed by GitHub
parent 5f531ac9b0
commit 6ecc1c14d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,7 +168,7 @@ void TuyaLight::write_state(light::LightState *state) {
if (brightness > 0.0f || !color_interlock_) {
if (this->color_temperature_id_.has_value()) {
uint32_t color_temp_int = static_cast<uint32_t>(color_temperature * this->color_temperature_max_value_);
uint32_t color_temp_int = static_cast<uint32_t>(roundf(color_temperature * this->color_temperature_max_value_));
if (this->color_temperature_invert_) {
color_temp_int = this->color_temperature_max_value_ - color_temp_int;
}