1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 23:21:54 +00:00

[tuya] allow enum for eco id (#11544)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
Samuel Sieb
2025-10-27 17:20:21 -07:00
committed by GitHub
parent ce8a6a6c43
commit 1e9309ffff
2 changed files with 8 additions and 1 deletions

View File

@@ -67,7 +67,9 @@ void TuyaClimate::setup() {
}
if (this->eco_id_.has_value()) {
this->parent_->register_listener(*this->eco_id_, [this](const TuyaDatapoint &datapoint) {
// Whether data type is BOOL or ENUM, it will still be a 1 or a 0, so the functions below are valid in both cases
this->eco_ = datapoint.value_bool;
this->eco_type_ = datapoint.type;
ESP_LOGV(TAG, "MCU reported eco is: %s", ONOFF(this->eco_));
this->compute_preset_();
this->compute_target_temperature_();
@@ -176,7 +178,11 @@ void TuyaClimate::control(const climate::ClimateCall &call) {
if (this->eco_id_.has_value()) {
const bool eco = preset == climate::CLIMATE_PRESET_ECO;
ESP_LOGV(TAG, "Setting eco: %s", ONOFF(eco));
this->parent_->set_boolean_datapoint_value(*this->eco_id_, eco);
if (this->eco_type_ == TuyaDatapointType::ENUM) {
this->parent_->set_enum_datapoint_value(*this->eco_id_, eco);
} else {
this->parent_->set_boolean_datapoint_value(*this->eco_id_, eco);
}
}
if (this->sleep_id_.has_value()) {
const bool sleep = preset == climate::CLIMATE_PRESET_SLEEP;

View File

@@ -104,6 +104,7 @@ class TuyaClimate : public climate::Climate, public Component {
optional<uint8_t> eco_id_{};
optional<uint8_t> sleep_id_{};
optional<float> eco_temperature_{};
TuyaDatapointType eco_type_{};
uint8_t active_state_;
uint8_t fan_state_;
optional<uint8_t> swing_vertical_id_{};