7static const char *
const TAG =
"tuya.climate";
11 if (switch_id.has_value()) {
13 ESP_LOGV(TAG,
"MCU reported switch is: %s", ONOFF(datapoint.
value_bool));
37 if (active_state_id.has_value()) {
39 ESP_LOGV(TAG,
"MCU reported active state is: %u", datapoint.
value_enum);
46 if (target_temp_id.has_value()) {
53 ESP_LOGV(TAG,
"MCU reported manual target temperature is: %.1f", this->
manual_temperature_);
60 if (current_temp_id.has_value()) {
73 if (eco_id.has_value()) {
78 ESP_LOGV(TAG,
"MCU reported eco is: %s", ONOFF(this->
eco_));
85 if (sleep_id.has_value()) {
88 ESP_LOGV(TAG,
"MCU reported sleep is: %s", ONOFF(this->
sleep_));
95 if (swing_vert_id.has_value()) {
98 ESP_LOGV(TAG,
"MCU reported vertical swing is: %s", ONOFF(datapoint.
value_bool));
105 if (swing_horiz_id.has_value()) {
108 ESP_LOGV(TAG,
"MCU reported horizontal swing is: %s", ONOFF(datapoint.
value_bool));
115 if (fan_speed_id.has_value()) {
117 ESP_LOGV(TAG,
"MCU reported Fan Speed Mode is: %u", datapoint.
value_enum);
126 bool state_changed =
false;
130 ESP_LOGV(TAG,
"Heating state pin changed to: %s", ONOFF(heating_state));
132 state_changed =
true;
138 ESP_LOGV(TAG,
"Cooling state pin changed to: %s", ONOFF(cooling_state));
140 state_changed =
true;
152 if (
mode.has_value()) {
154 ESP_LOGV(TAG,
"Setting switch: %s", ONOFF(switch_state));
156 if (switch_dp_id.has_value()) {
162 if (active_state_dp_id.has_value()) {
165 if (heating_val.has_value())
169 if (cooling_val.has_value())
173 if (drying_val.has_value())
177 if (fanonly_val.has_value())
181 ESP_LOGW(TAG,
"Active state (mode) datapoint not configured");
188 auto target_temp =
call.get_target_temperature();
189 if (target_temp.has_value()) {
196 if (target_temp_dp_id.has_value()) {
202 auto preset_val =
call.get_preset();
203 if (preset_val.has_value()) {
205 auto eco_dp_id = this->
eco_id_;
206 if (eco_dp_id.has_value()) {
208 ESP_LOGV(TAG,
"Setting eco: %s", ONOFF(eco));
216 if (sleep_dp_id.has_value()) {
218 ESP_LOGV(TAG,
"Setting sleep: %s", ONOFF(sleep));
225 bool vertical_swing_changed =
false;
226 bool horizontal_swing_changed =
false;
228 auto swing_mode_val =
call.get_swing_mode();
229 if (swing_mode_val.has_value()) {
237 vertical_swing_changed =
true;
238 horizontal_swing_changed =
true;
246 vertical_swing_changed =
true;
247 horizontal_swing_changed =
true;
255 vertical_swing_changed =
true;
256 horizontal_swing_changed =
true;
264 vertical_swing_changed =
true;
265 horizontal_swing_changed =
true;
275 if (vertical_swing_changed && vert_dp_id.has_value()) {
281 if (horizontal_swing_changed && horiz_dp_id.has_value()) {
291 auto fan_mode_val =
call.get_fan_mode();
292 if (fan_mode_val.has_value()) {
295 uint8_t tuya_fan_speed;
318 if (fan_speed_dp_id.has_value()) {
339 if (this->
eco_id_.has_value()) {
345 if (this->
sleep_id_.has_value() || this->eco_id_.has_value()) {
373 LOG_CLIMATE(
"",
"Tuya Climate",
this);
375 if (switch_dp_id.has_value()) {
376 ESP_LOGCONFIG(TAG,
" Switch has datapoint ID %u", *switch_dp_id);
379 if (active_state_dp_id.has_value()) {
380 ESP_LOGCONFIG(TAG,
" Active state has datapoint ID %u", *active_state_dp_id);
383 if (target_temp_dp_id.has_value()) {
384 ESP_LOGCONFIG(TAG,
" Target Temperature has datapoint ID %u", *target_temp_dp_id);
387 if (current_temp_dp_id.has_value()) {
388 ESP_LOGCONFIG(TAG,
" Current Temperature has datapoint ID %u", *current_temp_dp_id);
392 auto eco_dp_id = this->
eco_id_;
393 if (eco_dp_id.has_value()) {
394 ESP_LOGCONFIG(TAG,
" Eco has datapoint ID %u", *eco_dp_id);
397 if (sleep_dp_id.has_value()) {
398 ESP_LOGCONFIG(TAG,
" Sleep has datapoint ID %u", *sleep_dp_id);
401 if (swing_vert_dp_id.has_value()) {
402 ESP_LOGCONFIG(TAG,
" Swing Vertical has datapoint ID %u", *swing_vert_dp_id);
405 if (swing_horiz_dp_id.has_value()) {
406 ESP_LOGCONFIG(TAG,
" Swing Horizontal has datapoint ID %u", *swing_horiz_dp_id);
413 }
else if (this->
sleep_) {
437 }
else if (this->
fan_speed_high_value_.has_value() && this->fan_state_ == this->fan_speed_high_value_) {
443 }
else if (this->
fan_speed_low_value_.has_value() && this->fan_state_ == this->fan_speed_low_value_) {
482 this->active_state_ == this->active_state_heating_value_) {
485 this->active_state_ == this->active_state_cooling_value_) {
488 this->active_state_ == this->active_state_drying_value_) {
491 this->active_state_ == this->active_state_fanonly_value_) {
498 this->active_state_ == this->active_state_heating_value_) {
502 this->active_state_ == this->active_state_cooling_value_) {
506 this->active_state_ == this->active_state_drying_value_) {
510 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.
Providing packet encoding functions for exchanging data with a remote host.