fix: stop tuya light state getting reset (#2401)

* fix: stop tuya light state getting reset

* fix typo
This commit is contained in:
irtimaled 2021-09-27 12:54:51 -07:00 committed by GitHub
parent 8c86a18dc6
commit 1ba560dc9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,6 +111,11 @@ void TuyaLight::write_state(light::LightState *state) {
state->current_values_as_brightness(&brightness);
}
if (!state->current_values.is_on() && this->switch_id_.has_value()) {
parent_->set_boolean_datapoint_value(*this->switch_id_, false);
return;
}
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_);
@ -138,7 +143,7 @@ void TuyaLight::write_state(light::LightState *state) {
}
if (this->switch_id_.has_value()) {
parent_->set_boolean_datapoint_value(*this->switch_id_, state->current_values.is_on());
parent_->set_boolean_datapoint_value(*this->switch_id_, true);
}
}