1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-12 07:58:17 +00:00

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); 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 (brightness > 0.0f || !color_interlock_) {
if (this->color_temperature_id_.has_value()) { 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>(color_temperature * this->color_temperature_max_value_);
@ -138,7 +143,7 @@ void TuyaLight::write_state(light::LightState *state) {
} }
if (this->switch_id_.has_value()) { 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);
} }
} }