ESPHome  2024.4.1
demo_climate.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace demo {
8 
9 enum class DemoClimateType {
10  TYPE_1,
11  TYPE_2,
12  TYPE_3,
13 };
14 
15 class DemoClimate : public climate::Climate, public Component {
16  public:
17  void set_type(DemoClimateType type) { type_ = type; }
18  void setup() override {
19  switch (type_) {
21  this->current_temperature = 20.0;
22  this->target_temperature = 21.0;
24  this->action = climate::CLIMATE_ACTION_HEATING;
25  break;
27  this->target_temperature = 21.5;
29  this->action = climate::CLIMATE_ACTION_COOLING;
31  this->custom_preset = {"My Preset"};
32  break;
34  this->current_temperature = 21.5;
35  this->target_temperature_low = 21.0;
36  this->target_temperature_high = 22.5;
38  this->custom_fan_mode = {"Auto Low"};
41  break;
42  }
43  this->publish_state();
44  }
45 
46  protected:
47  void control(const climate::ClimateCall &call) override {
48  if (call.get_mode().has_value()) {
49  this->mode = *call.get_mode();
50  }
51  if (call.get_target_temperature().has_value()) {
53  }
56  }
59  }
60  if (call.get_fan_mode().has_value()) {
61  this->fan_mode = *call.get_fan_mode();
62  this->custom_fan_mode.reset();
63  }
64  if (call.get_swing_mode().has_value()) {
65  this->swing_mode = *call.get_swing_mode();
66  }
67  if (call.get_custom_fan_mode().has_value()) {
68  this->custom_fan_mode = *call.get_custom_fan_mode();
69  this->fan_mode.reset();
70  }
71  if (call.get_preset().has_value()) {
72  this->preset = *call.get_preset();
73  this->custom_preset.reset();
74  }
75  if (call.get_custom_preset().has_value()) {
76  this->custom_preset = *call.get_custom_preset();
77  this->preset.reset();
78  }
79  this->publish_state();
80  }
82  climate::ClimateTraits traits{};
83  switch (type_) {
85  traits.set_supports_current_temperature(true);
86  traits.set_supported_modes({
89  });
90  traits.set_supports_action(true);
91  traits.set_visual_temperature_step(0.5);
92  break;
94  traits.set_supports_current_temperature(false);
95  traits.set_supported_modes({
102  });
103  traits.set_supports_action(true);
104  traits.set_supported_fan_modes({
115  });
116  traits.set_supported_custom_fan_modes({"Auto Low", "Auto High"});
117  traits.set_supported_swing_modes({
122  });
123  traits.set_supported_custom_presets({"My Preset"});
124  break;
126  traits.set_supports_current_temperature(true);
127  traits.set_supports_two_point_target_temperature(true);
128  traits.set_supported_modes({
133  });
134  traits.set_supported_custom_fan_modes({"Auto Low", "Auto High"});
135  traits.set_supported_swing_modes({
138  });
139  traits.set_supported_presets({
148  });
149  break;
150  }
151  return traits;
152  }
153 
155 };
156 
157 } // namespace demo
158 } // namespace esphome
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
The fan mode is set to Low.
Definition: climate_mode.h:54
The fan mode is set to Quiet.
Definition: climate_mode.h:66
float target_temperature_low
Definition: climate.h:585
The fan mode is set to Both.
Definition: climate_mode.h:74
climate::ClimateTraits traits() override
Definition: demo_climate.h:81
Device is in home preset.
Definition: climate_mode.h:86
const optional< ClimateMode > & get_mode() const
Definition: climate.cpp:273
The fan mode is set to Middle.
Definition: climate_mode.h:60
This class contains all static data for climate devices.
The climate device is set to heat to reach the target temperature.
Definition: climate_mode.h:18
void control(const climate::ClimateCall &call) override
Definition: demo_climate.h:47
const optional< float > & get_target_temperature_low() const
Definition: climate.cpp:275
The fan mode is set to Diffuse.
Definition: climate_mode.h:64
bool has_value() const
Definition: optional.h:87
The climate device is set to dry/humidity mode.
Definition: climate_mode.h:22
float target_temperature_high
Definition: climate.h:586
ClimateSwingMode swing_mode
Definition: climate.h:581
Device is prepared for sleep.
Definition: climate_mode.h:96
Device is in away preset.
Definition: climate_mode.h:88
Device is in comfort preset.
Definition: climate_mode.h:92
const optional< std::string > & get_custom_preset() const
Definition: climate.cpp:281
The fan mode is set to Horizontal.
Definition: climate_mode.h:78
The climate device is set to cool to reach the target temperature.
Definition: climate_mode.h:16
Device is reacting to activity (e.g., movement sensors)
Definition: climate_mode.h:98
const optional< ClimatePreset > & get_preset() const
Definition: climate.cpp:280
The fan mode is set to Auto.
Definition: climate_mode.h:52
uint8_t custom_preset
Definition: climate.h:579
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:151
uint8_t type
The climate device is adjusting the temperatre dynamically.
Definition: climate_mode.h:27
The climate device is set to heat/cool to reach the target temperature.
Definition: climate_mode.h:14
The fan mode is set to Vertical.
Definition: climate_mode.h:76
The climate device is actively heating.
Definition: climate_mode.h:37
void set_type(DemoClimateType type)
Definition: demo_climate.h:17
The fan mode is set to Focus.
Definition: climate_mode.h:62
const optional< std::string > & get_custom_fan_mode() const
Definition: climate.cpp:279
The fan mode is set to Off.
Definition: climate_mode.h:50
const optional< float > & get_target_temperature() const
Definition: climate.cpp:274
The fan mode is set to High.
Definition: climate_mode.h:58
The swing mode is set to Off.
Definition: climate_mode.h:72
The climate device is off.
Definition: climate_mode.h:12
ClimateFanMode fan_mode
Definition: climate.h:573
const optional< ClimateFanMode > & get_fan_mode() const
Definition: climate.cpp:278
Device is in boost preset.
Definition: climate_mode.h:90
The fan mode is set to On.
Definition: climate_mode.h:48
const optional< ClimateSwingMode > & get_swing_mode() const
Definition: climate.cpp:282
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Device is running an energy-saving preset.
Definition: climate_mode.h:94
The fan mode is set to Medium.
Definition: climate_mode.h:56
const optional< float > & get_target_temperature_high() const
Definition: climate.cpp:276
The climate device only has the fan enabled, no heating or cooling is taking place.
Definition: climate_mode.h:20
The climate device is actively cooling.
Definition: climate_mode.h:35
uint8_t custom_fan_mode
Definition: climate.h:574
float target_temperature
Definition: climate.h:583
ClimatePreset preset
Definition: climate.h:578
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:168