ESPHome  2024.4.1
tuya_climate.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace tuya {
9 
10 class TuyaClimate : public climate::Climate, public Component {
11  public:
12  void setup() override;
13  void loop() override;
14  void dump_config() override;
15  void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
16  void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
17  void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
18  void set_active_state_id(uint8_t state_id) { this->active_state_id_ = state_id; }
19  void set_active_state_heating_value(uint8_t value) { this->active_state_heating_value_ = value; }
20  void set_active_state_cooling_value(uint8_t value) { this->active_state_cooling_value_ = value; }
21  void set_active_state_drying_value(uint8_t value) { this->active_state_drying_value_ = value; }
22  void set_active_state_fanonly_value(uint8_t value) { this->active_state_fanonly_value_ = value; }
23  void set_heating_state_pin(GPIOPin *pin) { this->heating_state_pin_ = pin; }
24  void set_cooling_state_pin(GPIOPin *pin) { this->cooling_state_pin_ = pin; }
25  void set_swing_vertical_id(uint8_t swing_vertical_id) { this->swing_vertical_id_ = swing_vertical_id; }
26  void set_swing_horizontal_id(uint8_t swing_horizontal_id) { this->swing_horizontal_id_ = swing_horizontal_id; }
27  void set_fan_speed_id(uint8_t fan_speed_id) { this->fan_speed_id_ = fan_speed_id; }
28  void set_fan_speed_low_value(uint8_t fan_speed_low_value) { this->fan_speed_low_value_ = fan_speed_low_value; }
29  void set_fan_speed_medium_value(uint8_t fan_speed_medium_value) {
30  this->fan_speed_medium_value_ = fan_speed_medium_value;
31  }
32  void set_fan_speed_middle_value(uint8_t fan_speed_middle_value) {
33  this->fan_speed_middle_value_ = fan_speed_middle_value;
34  }
35  void set_fan_speed_high_value(uint8_t fan_speed_high_value) { this->fan_speed_high_value_ = fan_speed_high_value; }
36  void set_fan_speed_auto_value(uint8_t fan_speed_auto_value) { this->fan_speed_auto_value_ = fan_speed_auto_value; }
37  void set_target_temperature_id(uint8_t target_temperature_id) {
38  this->target_temperature_id_ = target_temperature_id;
39  }
40  void set_current_temperature_id(uint8_t current_temperature_id) {
41  this->current_temperature_id_ = current_temperature_id;
42  }
43  void set_current_temperature_multiplier(float temperature_multiplier) {
44  this->current_temperature_multiplier_ = temperature_multiplier;
45  }
46  void set_target_temperature_multiplier(float temperature_multiplier) {
47  this->target_temperature_multiplier_ = temperature_multiplier;
48  }
49  void set_eco_id(uint8_t eco_id) { this->eco_id_ = eco_id; }
50  void set_eco_temperature(float eco_temperature) { this->eco_temperature_ = eco_temperature; }
51  void set_sleep_id(uint8_t sleep_id) { this->sleep_id_ = sleep_id; }
52 
54 
55  void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
56 
57  protected:
59  void control(const climate::ClimateCall &call) override;
60 
62  void control_swing_mode_(const climate::ClimateCall &call);
63 
65  void control_fan_mode_(const climate::ClimateCall &call);
66 
68  climate::ClimateTraits traits() override;
69 
71  void compute_preset_();
72 
75 
77  void compute_state_();
78 
80  void compute_swingmode_();
81 
83  void compute_fanmode_();
84 
87 
103  float hysteresis_{1.0f};
107  uint8_t active_state_;
108  uint8_t fan_state_;
117  bool swing_vertical_{false};
118  bool swing_horizontal_{false};
119  bool heating_state_{false};
120  bool cooling_state_{false};
122  bool eco_;
123  bool sleep_;
124  bool reports_fahrenheit_{false};
125 };
126 
127 } // namespace tuya
128 } // namespace esphome
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
void set_active_state_fanonly_value(uint8_t value)
Definition: tuya_climate.h:22
optional< uint8_t > sleep_id_
Definition: tuya_climate.h:105
optional< uint8_t > fan_speed_low_value_
Definition: tuya_climate.h:112
optional< uint8_t > swing_vertical_id_
Definition: tuya_climate.h:109
void switch_to_action_(climate::ClimateAction action)
Switch the climate device to the given climate mode.
This class contains all static data for climate devices.
void control_fan_mode_(const climate::ClimateCall &call)
Override control to change settings of fan mode.
void set_current_temperature_id(uint8_t current_temperature_id)
Definition: tuya_climate.h:40
optional< uint8_t > fan_speed_medium_value_
Definition: tuya_climate.h:113
void set_tuya_parent(Tuya *parent)
Definition: tuya_climate.h:55
optional< uint8_t > active_state_cooling_value_
Definition: tuya_climate.h:94
optional< uint8_t > swing_horizontal_id_
Definition: tuya_climate.h:110
void set_active_state_cooling_value(uint8_t value)
Definition: tuya_climate.h:20
void set_fan_speed_id(uint8_t fan_speed_id)
Definition: tuya_climate.h:27
void set_eco_temperature(float eco_temperature)
Definition: tuya_climate.h:50
void set_target_temperature_multiplier(float temperature_multiplier)
Definition: tuya_climate.h:46
void set_supports_cool(bool supports_cool)
Definition: tuya_climate.h:16
optional< uint8_t > switch_id_
Definition: tuya_climate.h:91
void compute_swingmode_()
Re-Compute the swing mode of this climate controller.
optional< uint8_t > fan_speed_auto_value_
Definition: tuya_climate.h:116
void set_fan_speed_middle_value(uint8_t fan_speed_middle_value)
Definition: tuya_climate.h:32
optional< uint8_t > active_state_drying_value_
Definition: tuya_climate.h:95
void compute_target_temperature_()
Re-compute the target temperature of this climate controller.
void set_supports_heat(bool supports_heat)
Definition: tuya_climate.h:15
void compute_fanmode_()
Re-Compute the fan mode of this climate controller.
void set_switch_id(uint8_t switch_id)
Definition: tuya_climate.h:17
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
optional< uint8_t > active_state_fanonly_value_
Definition: tuya_climate.h:96
optional< uint8_t > active_state_id_
Definition: tuya_climate.h:92
optional< uint8_t > eco_id_
Definition: tuya_climate.h:104
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
Definition: climate_mode.h:31
void set_swing_horizontal_id(uint8_t swing_horizontal_id)
Definition: tuya_climate.h:26
void set_sleep_id(uint8_t sleep_id)
Definition: tuya_climate.h:51
optional< float > eco_temperature_
Definition: tuya_climate.h:106
void set_fan_speed_high_value(uint8_t fan_speed_high_value)
Definition: tuya_climate.h:35
void set_fan_speed_low_value(uint8_t fan_speed_low_value)
Definition: tuya_climate.h:28
optional< uint8_t > fan_speed_middle_value_
Definition: tuya_climate.h:114
optional< uint8_t > fan_speed_high_value_
Definition: tuya_climate.h:115
void set_active_state_id(uint8_t state_id)
Definition: tuya_climate.h:18
void set_heating_state_pin(GPIOPin *pin)
Definition: tuya_climate.h:23
void set_current_temperature_multiplier(float temperature_multiplier)
Definition: tuya_climate.h:43
optional< uint8_t > active_state_heating_value_
Definition: tuya_climate.h:93
void set_fan_speed_medium_value(uint8_t fan_speed_medium_value)
Definition: tuya_climate.h:29
climate::ClimateTraits traits() override
Return the traits of this controller.
void set_target_temperature_id(uint8_t target_temperature_id)
Definition: tuya_climate.h:37
void set_active_state_heating_value(uint8_t value)
Definition: tuya_climate.h:19
void set_fan_speed_auto_value(uint8_t fan_speed_auto_value)
Definition: tuya_climate.h:36
void set_cooling_state_pin(GPIOPin *pin)
Definition: tuya_climate.h:24
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
optional< uint8_t > fan_speed_id_
Definition: tuya_climate.h:111
void set_active_state_drying_value(uint8_t value)
Definition: tuya_climate.h:21
void compute_state_()
Re-compute the state of this climate controller.
optional< uint8_t > target_temperature_id_
Definition: tuya_climate.h:99
void control_swing_mode_(const climate::ClimateCall &call)
Override control to change settings of swing mode.
void compute_preset_()
Re-compute the active preset of this climate controller.
void set_swing_vertical_id(uint8_t swing_vertical_id)
Definition: tuya_climate.h:25
optional< uint8_t > current_temperature_id_
Definition: tuya_climate.h:100
ClimateAction action
The active state of the climate device.
Definition: climate.h:176
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:168
void set_eco_id(uint8_t eco_id)
Definition: tuya_climate.h:49