6static const char *
const TAG =
"tuya.climate";
10 if (switch_id.has_value()) {
12 ESP_LOGV(TAG,
"MCU reported switch is: %s", ONOFF(datapoint.
value_bool));
36 if (active_state_id.has_value()) {
38 ESP_LOGV(TAG,
"MCU reported active state is: %u", datapoint.
value_enum);
45 if (target_temp_id.has_value()) {
52 ESP_LOGV(TAG,
"MCU reported manual target temperature is: %.1f", this->
manual_temperature_);
59 if (current_temp_id.has_value()) {
72 if (eco_id.has_value()) {
77 ESP_LOGV(TAG,
"MCU reported eco is: %s", ONOFF(this->
eco_));
84 if (sleep_id.has_value()) {
87 ESP_LOGV(TAG,
"MCU reported sleep is: %s", ONOFF(this->
sleep_));
94 if (swing_vert_id.has_value()) {
97 ESP_LOGV(TAG,
"MCU reported vertical swing is: %s", ONOFF(datapoint.
value_bool));
104 if (swing_horiz_id.has_value()) {
107 ESP_LOGV(TAG,
"MCU reported horizontal swing is: %s", ONOFF(datapoint.
value_bool));
114 if (fan_speed_id.has_value()) {
116 ESP_LOGV(TAG,
"MCU reported Fan Speed Mode is: %u", datapoint.
value_enum);
125 bool state_changed =
false;
129 ESP_LOGV(TAG,
"Heating state pin changed to: %s", ONOFF(heating_state));
131 state_changed =
true;
137 ESP_LOGV(TAG,
"Cooling state pin changed to: %s", ONOFF(cooling_state));
139 state_changed =
true;
151 if (
mode.has_value()) {
153 ESP_LOGV(TAG,
"Setting switch: %s", ONOFF(switch_state));
155 if (switch_dp_id.has_value()) {
161 if (active_state_dp_id.has_value()) {
164 if (heating_val.has_value())
168 if (cooling_val.has_value())
172 if (drying_val.has_value())
176 if (fanonly_val.has_value())
180 ESP_LOGW(TAG,
"Active state (mode) datapoint not configured");
187 auto target_temp =
call.get_target_temperature();
188 if (target_temp.has_value()) {
195 if (target_temp_dp_id.has_value()) {
201 auto preset_val =
call.get_preset();
202 if (preset_val.has_value()) {
204 auto eco_dp_id = this->
eco_id_;
205 if (eco_dp_id.has_value()) {
207 ESP_LOGV(TAG,
"Setting eco: %s", ONOFF(eco));
215 if (sleep_dp_id.has_value()) {
217 ESP_LOGV(TAG,
"Setting sleep: %s", ONOFF(sleep));
224 bool vertical_swing_changed =
false;
225 bool horizontal_swing_changed =
false;
227 auto swing_mode_val =
call.get_swing_mode();
228 if (swing_mode_val.has_value()) {
236 vertical_swing_changed =
true;
237 horizontal_swing_changed =
true;
245 vertical_swing_changed =
true;
246 horizontal_swing_changed =
true;
254 vertical_swing_changed =
true;
255 horizontal_swing_changed =
true;
263 vertical_swing_changed =
true;
264 horizontal_swing_changed =
true;
274 if (vertical_swing_changed && vert_dp_id.has_value()) {
280 if (horizontal_swing_changed && horiz_dp_id.has_value()) {
290 auto fan_mode_val =
call.get_fan_mode();
291 if (fan_mode_val.has_value()) {
294 uint8_t tuya_fan_speed;
317 if (fan_speed_dp_id.has_value()) {
338 if (this->
eco_id_.has_value()) {
344 if (this->
sleep_id_.has_value() || this->eco_id_.has_value()) {
372 LOG_CLIMATE(
"",
"Tuya Climate",
this);
374 if (switch_dp_id.has_value()) {
375 ESP_LOGCONFIG(TAG,
" Switch has datapoint ID %u", *switch_dp_id);
378 if (active_state_dp_id.has_value()) {
379 ESP_LOGCONFIG(TAG,
" Active state has datapoint ID %u", *active_state_dp_id);
382 if (target_temp_dp_id.has_value()) {
383 ESP_LOGCONFIG(TAG,
" Target Temperature has datapoint ID %u", *target_temp_dp_id);
386 if (current_temp_dp_id.has_value()) {
387 ESP_LOGCONFIG(TAG,
" Current Temperature has datapoint ID %u", *current_temp_dp_id);
391 auto eco_dp_id = this->
eco_id_;
392 if (eco_dp_id.has_value()) {
393 ESP_LOGCONFIG(TAG,
" Eco has datapoint ID %u", *eco_dp_id);
396 if (sleep_dp_id.has_value()) {
397 ESP_LOGCONFIG(TAG,
" Sleep has datapoint ID %u", *sleep_dp_id);
400 if (swing_vert_dp_id.has_value()) {
401 ESP_LOGCONFIG(TAG,
" Swing Vertical has datapoint ID %u", *swing_vert_dp_id);
404 if (swing_horiz_dp_id.has_value()) {
405 ESP_LOGCONFIG(TAG,
" Swing Horizontal has datapoint ID %u", *swing_horiz_dp_id);
412 }
else if (this->
sleep_) {
436 }
else if (this->
fan_speed_high_value_.has_value() && this->fan_state_ == this->fan_speed_high_value_) {
442 }
else if (this->
fan_speed_low_value_.has_value() && this->fan_state_ == this->fan_speed_low_value_) {
481 this->active_state_ == this->active_state_heating_value_) {
484 this->active_state_ == this->active_state_cooling_value_) {
487 this->active_state_ == this->active_state_drying_value_) {
490 this->active_state_ == this->active_state_fanonly_value_) {
497 this->active_state_ == this->active_state_heating_value_) {
501 this->active_state_ == this->active_state_cooling_value_) {
505 this->active_state_ == this->active_state_drying_value_) {
509 this->active_state_ == this->active_state_fanonly_value_) {
virtual bool digital_read()=0
This class is used to encode all control actions on a climate device.
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
float current_temperature
The current temperature of the climate device, as reported from the integration.
ClimateAction action
The active state of the climate device.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimatePreset > preset
The active preset of the climate device.
void add_feature_flags(uint32_t feature_flags)
void add_supported_fan_mode(ClimateFanMode mode)
void add_supported_preset(ClimatePreset preset)
void set_supported_swing_modes(ClimateSwingModeMask modes)
void add_supported_mode(ClimateMode mode)
optional< uint8_t > fan_speed_high_value_
float target_temperature_multiplier_
GPIOPin * heating_state_pin_
void switch_to_action_(climate::ClimateAction action)
Switch the climate device to the given climate mode.
optional< uint8_t > swing_vertical_id_
void compute_fanmode_()
Re-Compute the fan mode of this climate controller.
optional< uint8_t > fan_speed_low_value_
optional< uint8_t > current_temperature_id_
float current_temperature_multiplier_
void control_fan_mode_(const climate::ClimateCall &call)
Override control to change settings of fan mode.
void compute_target_temperature_()
Re-compute the target temperature of this climate controller.
optional< uint8_t > active_state_id_
optional< uint8_t > fan_speed_auto_value_
void compute_swingmode_()
Re-Compute the swing mode of this climate controller.
void dump_config() override
TuyaDatapointType eco_type_
void compute_preset_()
Re-compute the active preset of this climate controller.
optional< uint8_t > swing_horizontal_id_
GPIOPin * cooling_state_pin_
optional< float > eco_temperature_
optional< uint8_t > active_state_fanonly_value_
optional< uint8_t > fan_speed_medium_value_
float manual_temperature_
void control_swing_mode_(const climate::ClimateCall &call)
Override control to change settings of swing mode.
optional< uint8_t > sleep_id_
void compute_state_()
Re-compute the state of this climate controller.
optional< uint8_t > fan_speed_middle_value_
optional< uint8_t > active_state_cooling_value_
optional< uint8_t > active_state_drying_value_
climate::ClimateTraits traits() override
Return the traits of this controller.
optional< uint8_t > fan_speed_id_
optional< uint8_t > active_state_heating_value_
optional< uint8_t > target_temperature_id_
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
optional< uint8_t > eco_id_
optional< uint8_t > switch_id_
void set_boolean_datapoint_value(uint8_t datapoint_id, bool value)
void set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value)
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
void set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value)
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_SUPPORTS_ACTION
ClimatePreset
Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits....
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
@ CLIMATE_ACTION_OFF
The climate device is off (inactive or no power)
@ CLIMATE_ACTION_IDLE
The climate device is idle (monitoring climate but no action needed)
@ CLIMATE_ACTION_DRYING
The climate device is drying.
@ CLIMATE_ACTION_HEATING
The climate device is actively heating.
@ CLIMATE_ACTION_COOLING
The climate device is actively cooling.
@ CLIMATE_ACTION_FAN
The climate device is in fan only mode.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_MIDDLE
The fan mode is set to Middle.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.