ESPHome  2023.11.6
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_heating_state_pin(GPIOPin *pin) { this->heating_state_pin_ = pin; }
22  void set_cooling_state_pin(GPIOPin *pin) { this->cooling_state_pin_ = pin; }
23  void set_target_temperature_id(uint8_t target_temperature_id) {
24  this->target_temperature_id_ = target_temperature_id;
25  }
26  void set_current_temperature_id(uint8_t current_temperature_id) {
27  this->current_temperature_id_ = current_temperature_id;
28  }
29  void set_current_temperature_multiplier(float temperature_multiplier) {
30  this->current_temperature_multiplier_ = temperature_multiplier;
31  }
32  void set_target_temperature_multiplier(float temperature_multiplier) {
33  this->target_temperature_multiplier_ = temperature_multiplier;
34  }
35  void set_eco_id(uint8_t eco_id) { this->eco_id_ = eco_id; }
36  void set_eco_temperature(float eco_temperature) { this->eco_temperature_ = eco_temperature; }
37 
39 
40  void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
41 
42  protected:
44  void control(const climate::ClimateCall &call) override;
45 
47  climate::ClimateTraits traits() override;
48 
50  void compute_preset_();
51 
54 
56  void compute_state_();
57 
60 
74  float hysteresis_{1.0f};
77  uint8_t active_state_;
78  bool heating_state_{false};
79  bool cooling_state_{false};
81  bool eco_;
82  bool reports_fahrenheit_{false};
83 };
84 
85 } // namespace tuya
86 } // namespace esphome
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
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 set_current_temperature_id(uint8_t current_temperature_id)
Definition: tuya_climate.h:26
void set_tuya_parent(Tuya *parent)
Definition: tuya_climate.h:40
optional< uint8_t > active_state_cooling_value_
Definition: tuya_climate.h:67
void set_active_state_cooling_value(uint8_t value)
Definition: tuya_climate.h:20
void set_eco_temperature(float eco_temperature)
Definition: tuya_climate.h:36
void set_target_temperature_multiplier(float temperature_multiplier)
Definition: tuya_climate.h:32
void set_supports_cool(bool supports_cool)
Definition: tuya_climate.h:16
optional< uint8_t > switch_id_
Definition: tuya_climate.h:64
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 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_id_
Definition: tuya_climate.h:65
optional< uint8_t > eco_id_
Definition: tuya_climate.h:75
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
Definition: climate_mode.h:31
optional< float > eco_temperature_
Definition: tuya_climate.h:76
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:21
void set_current_temperature_multiplier(float temperature_multiplier)
Definition: tuya_climate.h:29
optional< uint8_t > active_state_heating_value_
Definition: tuya_climate.h:66
climate::ClimateTraits traits() override
Return the traits of this controller.
void set_target_temperature_id(uint8_t target_temperature_id)
Definition: tuya_climate.h:23
void set_active_state_heating_value(uint8_t value)
Definition: tuya_climate.h:19
void set_cooling_state_pin(GPIOPin *pin)
Definition: tuya_climate.h:22
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void compute_state_()
Re-compute the state of this climate controller.
optional< uint8_t > target_temperature_id_
Definition: tuya_climate.h:70
void compute_preset_()
Re-compute the active preset of this climate controller.
optional< uint8_t > current_temperature_id_
Definition: tuya_climate.h:71
ClimateAction action
The active state of the climate device.
Definition: climate.h:166
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:161
void set_eco_id(uint8_t eco_id)
Definition: tuya_climate.h:35