Break the Tuya set_datapoint_value method into separate methods per datapoint type (#2059)

Co-authored-by: Chris Nussbaum <chris.nussbaum@protolabs.com>
Co-authored-by: Trevor North <trevor@freedisc.co.uk>
This commit is contained in:
Chris Nussbaum
2021-08-10 14:44:31 -05:00
committed by GitHub
parent 1771e673d2
commit 6144ce1fe0
6 changed files with 83 additions and 42 deletions
@@ -54,14 +54,14 @@ void TuyaClimate::control(const climate::ClimateCall &call) {
if (call.get_mode().has_value()) {
const bool switch_state = *call.get_mode() != climate::CLIMATE_MODE_OFF;
ESP_LOGV(TAG, "Setting switch: %s", ONOFF(switch_state));
this->parent_->set_datapoint_value(*this->switch_id_, switch_state);
this->parent_->set_boolean_datapoint_value(*this->switch_id_, switch_state);
}
if (call.get_target_temperature().has_value()) {
const float target_temperature = *call.get_target_temperature();
ESP_LOGV(TAG, "Setting target temperature: %.1f", target_temperature);
this->parent_->set_datapoint_value(*this->target_temperature_id_,
(int) (target_temperature / this->target_temperature_multiplier_));
this->parent_->set_integer_datapoint_value(*this->target_temperature_id_,
(int) (target_temperature / this->target_temperature_multiplier_));
}
}