ESPHome 2026.5.1
Loading...
Searching...
No Matches
tuya_climate.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::tuya {
8
9class TuyaClimate : public climate::Climate, public Component {
10 public:
11 void setup() override;
12 void loop() override;
13 void dump_config() override;
14 void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
15 void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
16 void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
17 void set_active_state_id(uint8_t state_id) { this->active_state_id_ = state_id; }
18 void set_active_state_heating_value(uint8_t value) { this->active_state_heating_value_ = value; }
19 void set_active_state_cooling_value(uint8_t value) { this->active_state_cooling_value_ = value; }
20 void set_active_state_drying_value(uint8_t value) { this->active_state_drying_value_ = value; }
21 void set_active_state_fanonly_value(uint8_t value) { this->active_state_fanonly_value_ = value; }
24 void set_swing_vertical_id(uint8_t swing_vertical_id) { this->swing_vertical_id_ = swing_vertical_id; }
25 void set_swing_horizontal_id(uint8_t swing_horizontal_id) { this->swing_horizontal_id_ = swing_horizontal_id; }
26 void set_fan_speed_id(uint8_t fan_speed_id) { this->fan_speed_id_ = fan_speed_id; }
27 void set_fan_speed_low_value(uint8_t fan_speed_low_value) { this->fan_speed_low_value_ = fan_speed_low_value; }
28 void set_fan_speed_medium_value(uint8_t fan_speed_medium_value) {
29 this->fan_speed_medium_value_ = fan_speed_medium_value;
30 }
31 void set_fan_speed_middle_value(uint8_t fan_speed_middle_value) {
32 this->fan_speed_middle_value_ = fan_speed_middle_value;
33 }
34 void set_fan_speed_high_value(uint8_t fan_speed_high_value) { this->fan_speed_high_value_ = fan_speed_high_value; }
35 void set_fan_speed_auto_value(uint8_t fan_speed_auto_value) { this->fan_speed_auto_value_ = fan_speed_auto_value; }
36 void set_target_temperature_id(uint8_t target_temperature_id) {
37 this->target_temperature_id_ = target_temperature_id;
38 }
39 void set_current_temperature_id(uint8_t current_temperature_id) {
40 this->current_temperature_id_ = current_temperature_id;
41 }
42 void set_current_temperature_multiplier(float temperature_multiplier) {
43 this->current_temperature_multiplier_ = temperature_multiplier;
44 }
45 void set_target_temperature_multiplier(float temperature_multiplier) {
46 this->target_temperature_multiplier_ = temperature_multiplier;
47 }
48 void set_eco_id(uint8_t eco_id) { this->eco_id_ = eco_id; }
49 void set_eco_temperature(float eco_temperature) { this->eco_temperature_ = eco_temperature; }
50 void set_sleep_id(uint8_t sleep_id) { this->sleep_id_ = sleep_id; }
51
53
54 void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
55
56 protected:
58 void control(const climate::ClimateCall &call) override;
59
62
65
68
70 void compute_preset_();
71
74
76 void compute_state_();
77
79 void compute_swingmode_();
80
82 void compute_fanmode_();
83
86
90 optional<uint8_t> switch_id_{};
91 optional<uint8_t> active_state_id_{};
92 optional<uint8_t> active_state_heating_value_{};
93 optional<uint8_t> active_state_cooling_value_{};
94 optional<uint8_t> active_state_drying_value_{};
95 optional<uint8_t> active_state_fanonly_value_{};
98 optional<uint8_t> target_temperature_id_{};
99 optional<uint8_t> current_temperature_id_{};
102 float hysteresis_{1.0f};
103 optional<uint8_t> eco_id_{};
104 optional<uint8_t> sleep_id_{};
105 optional<float> eco_temperature_{};
107 uint8_t active_state_{0};
108 uint8_t fan_state_{0};
109 optional<uint8_t> swing_vertical_id_{};
110 optional<uint8_t> swing_horizontal_id_{};
111 optional<uint8_t> fan_speed_id_{};
112 optional<uint8_t> fan_speed_low_value_{};
113 optional<uint8_t> fan_speed_medium_value_{};
114 optional<uint8_t> fan_speed_middle_value_{};
115 optional<uint8_t> fan_speed_high_value_{};
116 optional<uint8_t> fan_speed_auto_value_{};
117 bool swing_vertical_{false};
118 bool swing_horizontal_{false};
119 bool heating_state_{false};
120 bool cooling_state_{false};
122 bool eco_{false};
123 bool sleep_{false};
125};
126
127} // namespace esphome::tuya
This class is used to encode all control actions on a climate device.
Definition climate.h:34
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:187
ClimateAction action
The active state of the climate device.
Definition climate.h:296
optional< uint8_t > fan_speed_high_value_
void set_active_state_cooling_value(uint8_t value)
void set_tuya_parent(Tuya *parent)
void set_supports_cool(bool supports_cool)
void set_swing_horizontal_id(uint8_t swing_horizontal_id)
void set_swing_vertical_id(uint8_t swing_vertical_id)
void switch_to_action_(climate::ClimateAction action)
Switch the climate device to the given climate mode.
void set_fan_speed_high_value(uint8_t fan_speed_high_value)
void set_cooling_state_pin(GPIOPin *pin)
void set_current_temperature_multiplier(float temperature_multiplier)
optional< uint8_t > swing_vertical_id_
void set_fan_speed_middle_value(uint8_t fan_speed_middle_value)
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_
void set_fan_speed_low_value(uint8_t fan_speed_low_value)
void control_fan_mode_(const climate::ClimateCall &call)
Override control to change settings of fan mode.
void set_switch_id(uint8_t switch_id)
void set_sleep_id(uint8_t sleep_id)
void compute_target_temperature_()
Re-compute the target temperature of this climate controller.
void set_current_temperature_id(uint8_t current_temperature_id)
optional< uint8_t > active_state_id_
void set_active_state_drying_value(uint8_t value)
void set_active_state_heating_value(uint8_t value)
optional< uint8_t > fan_speed_auto_value_
void compute_swingmode_()
Re-Compute the swing mode of this climate controller.
void set_eco_id(uint8_t eco_id)
TuyaDatapointType eco_type_
void set_target_temperature_id(uint8_t target_temperature_id)
void compute_preset_()
Re-compute the active preset of this climate controller.
optional< uint8_t > swing_horizontal_id_
void set_fan_speed_id(uint8_t fan_speed_id)
optional< float > eco_temperature_
optional< uint8_t > active_state_fanonly_value_
optional< uint8_t > fan_speed_medium_value_
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_
void set_fan_speed_medium_value(uint8_t fan_speed_medium_value)
optional< uint8_t > active_state_cooling_value_
void set_heating_state_pin(GPIOPin *pin)
optional< uint8_t > active_state_drying_value_
climate::ClimateTraits traits() override
Return the traits of this controller.
void set_active_state_fanonly_value(uint8_t value)
void set_active_state_id(uint8_t state_id)
optional< uint8_t > fan_speed_id_
optional< uint8_t > active_state_heating_value_
void set_fan_speed_auto_value(uint8_t fan_speed_auto_value)
optional< uint8_t > target_temperature_id_
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
void set_supports_heat(bool supports_heat)
void set_target_temperature_multiplier(float temperature_multiplier)
optional< uint8_t > eco_id_
optional< uint8_t > switch_id_
void set_eco_temperature(float eco_temperature)
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
TuyaDatapointType
Definition tuya.h:18