From e8c88062675d6a0187b0bc859a566c36334afd32 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 3 Mar 2026 13:32:25 -1000 Subject: [PATCH] expand all sites, part 5 --- esphome/components/tuya/cover/tuya_cover.cpp | 3 ++- esphome/components/tuya/fan/tuya_fan.cpp | 24 +++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/esphome/components/tuya/cover/tuya_cover.cpp b/esphome/components/tuya/cover/tuya_cover.cpp index bb956c612d..125afec048 100644 --- a/esphome/components/tuya/cover/tuya_cover.cpp +++ b/esphome/components/tuya/cover/tuya_cover.cpp @@ -72,7 +72,8 @@ void TuyaCover::control(const cover::CoverCall &call) { this->parent_->force_set_integer_datapoint_value(*this->position_id_, position_int); } } - if (auto pos_opt = call.get_position(); pos_opt.has_value()) { + auto pos_opt = call.get_position(); + if (pos_opt.has_value()) { auto pos = *pos_opt; if (this->control_id_.has_value() && (pos == COVER_OPEN || pos == COVER_CLOSED)) { if (pos == COVER_OPEN) { diff --git a/esphome/components/tuya/fan/tuya_fan.cpp b/esphome/components/tuya/fan/tuya_fan.cpp index ffe092b11b..a387606b77 100644 --- a/esphome/components/tuya/fan/tuya_fan.cpp +++ b/esphome/components/tuya/fan/tuya_fan.cpp @@ -88,13 +88,17 @@ fan::FanTraits TuyaFan::get_traits() { } void TuyaFan::control(const fan::FanCall &call) { - if (auto switch_id = this->switch_id_; switch_id.has_value()) { - if (auto state = call.get_state(); state.has_value()) { + auto switch_id = this->switch_id_; + if (switch_id.has_value()) { + auto state = call.get_state(); + if (state.has_value()) { this->parent_->set_boolean_datapoint_value(*switch_id, *state); } } - if (auto osc_id = this->oscillation_id_; osc_id.has_value()) { - if (auto oscillating = call.get_oscillating(); oscillating.has_value()) { + auto osc_id = this->oscillation_id_; + if (osc_id.has_value()) { + auto oscillating = call.get_oscillating(); + if (oscillating.has_value()) { if (this->oscillation_type_ == TuyaDatapointType::ENUM) { this->parent_->set_enum_datapoint_value(*osc_id, *oscillating); } else if (this->oscillation_type_ == TuyaDatapointType::BOOLEAN) { @@ -102,14 +106,18 @@ void TuyaFan::control(const fan::FanCall &call) { } } } - if (auto dir_id = this->direction_id_; dir_id.has_value()) { - if (auto direction = call.get_direction(); direction.has_value()) { + auto dir_id = this->direction_id_; + if (dir_id.has_value()) { + auto direction = call.get_direction(); + if (direction.has_value()) { bool enable = *direction == fan::FanDirection::REVERSE; this->parent_->set_enum_datapoint_value(*dir_id, enable); } } - if (auto spd_id = this->speed_id_; spd_id.has_value()) { - if (auto speed = call.get_speed(); speed.has_value()) { + auto spd_id = this->speed_id_; + if (spd_id.has_value()) { + auto speed = call.get_speed(); + if (speed.has_value()) { if (this->speed_type_ == TuyaDatapointType::ENUM) { this->parent_->set_enum_datapoint_value(*spd_id, *speed - 1); } else if (this->speed_type_ == TuyaDatapointType::INTEGER) {