ESPHome  2024.11.3
ac_adapter.cpp
Go to the documentation of this file.
1 #ifdef USE_ARDUINO
2 
3 #include "esphome/core/log.h"
4 #include "ac_adapter.h"
5 
6 namespace esphome {
7 namespace midea {
8 namespace ac {
9 
10 const char *const Constants::TAG = "midea";
11 const std::string Constants::FREEZE_PROTECTION = "freeze protection";
12 const std::string Constants::SILENT = "silent";
13 const std::string Constants::TURBO = "turbo";
14 
16  switch (mode) {
17  case MideaMode::MODE_AUTO:
23  case MideaMode::MODE_FAN_ONLY:
27  default:
29  }
30 }
31 
33  switch (mode) {
35  return MideaMode::MODE_AUTO;
37  return MideaMode::MODE_COOL;
39  return MideaMode::MODE_DRY;
41  return MideaMode::MODE_FAN_ONLY;
43  return MideaMode::MODE_HEAT;
44  default:
45  return MideaMode::MODE_OFF;
46  }
47 }
48 
50  switch (mode) {
51  case MideaSwingMode::SWING_VERTICAL:
53  case MideaSwingMode::SWING_HORIZONTAL:
55  case MideaSwingMode::SWING_BOTH:
57  default:
59  }
60 }
61 
63  switch (mode) {
65  return MideaSwingMode::SWING_VERTICAL;
67  return MideaSwingMode::SWING_HORIZONTAL;
69  return MideaSwingMode::SWING_BOTH;
70  default:
71  return MideaSwingMode::SWING_OFF;
72  }
73 }
74 
76  switch (mode) {
78  return MideaFanMode::FAN_LOW;
80  return MideaFanMode::FAN_MEDIUM;
83  default:
85  }
86 }
87 
89  switch (mode) {
92  case MideaFanMode::FAN_MEDIUM:
96  default:
98  }
99 }
100 
102  switch (mode) {
103  case MideaFanMode::FAN_SILENT:
104  case MideaFanMode::FAN_TURBO:
105  return true;
106  default:
107  return false;
108  }
109 }
110 
112  switch (mode) {
113  case MideaFanMode::FAN_SILENT:
114  return Constants::SILENT;
115  default:
116  return Constants::TURBO;
117  }
118 }
119 
121  if (mode == Constants::SILENT)
122  return MideaFanMode::FAN_SILENT;
123  return MideaFanMode::FAN_TURBO;
124 }
125 
127  switch (preset) {
129  return MideaPreset::PRESET_SLEEP;
131  return MideaPreset::PRESET_ECO;
133  return MideaPreset::PRESET_TURBO;
134  default:
135  return MideaPreset::PRESET_NONE;
136  }
137 }
138 
140  switch (preset) {
141  case MideaPreset::PRESET_SLEEP:
143  case MideaPreset::PRESET_ECO:
145  case MideaPreset::PRESET_TURBO:
147  default:
149  }
150 }
151 
152 bool Converters::is_custom_midea_preset(MideaPreset preset) { return preset == MideaPreset::PRESET_FREEZE_PROTECTION; }
153 
155 
156 MideaPreset Converters::to_midea_preset(const std::string &preset) { return MideaPreset::PRESET_FREEZE_PROTECTION; }
157 
158 void Converters::to_climate_traits(ClimateTraits &traits, const dudanov::midea::ac::Capabilities &capabilities) {
159  if (capabilities.supportAutoMode())
161  if (capabilities.supportCoolMode())
163  if (capabilities.supportHeatMode())
165  if (capabilities.supportDryMode())
167  if (capabilities.supportTurboPreset())
169  if (capabilities.supportEcoPreset())
171  if (capabilities.supportFrostProtectionPreset())
172  traits.add_supported_custom_preset(Constants::FREEZE_PROTECTION);
173 }
174 
175 } // namespace ac
176 } // namespace midea
177 } // namespace esphome
178 
179 #endif // USE_ARDUINO
static ClimateFanMode to_climate_fan_mode(MideaFanMode fan_mode)
Definition: ac_adapter.cpp:88
static const char *const TAG
Definition: ac_adapter.h:22
static const std::string & to_custom_climate_fan_mode(MideaFanMode fan_mode)
Definition: ac_adapter.cpp:111
This class contains all static data for climate devices.
static bool is_custom_midea_fan_mode(MideaFanMode fan_mode)
Definition: ac_adapter.cpp:101
void add_supported_custom_preset(const std::string &preset)
static void to_climate_traits(ClimateTraits &traits, const dudanov::midea::ac::Capabilities &capabilities)
Definition: ac_adapter.cpp:158
const uint32_t FAN_HIGH
Definition: whynter.cpp:31
const uint32_t FAN_LOW
Definition: whynter.cpp:33
BedJet is in Dry mode (high speed, no heat)
Definition: bedjet_const.h:30
BedJet is in Cool mode (actually "Fan only" mode)
Definition: bedjet_const.h:28
void add_supported_preset(ClimatePreset preset)
static MideaPreset to_midea_preset(ClimatePreset preset)
Definition: ac_adapter.cpp:126
dudanov::midea::ac::Mode MideaMode
Definition: ac_adapter.h:15
BedJet is in Heat mode (limited to 4 hours)
Definition: bedjet_const.h:22
static const std::string & to_custom_climate_preset(MideaPreset preset)
Definition: ac_adapter.cpp:154
static const std::string TURBO
Definition: ac_adapter.h:25
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:183
static const std::string FREEZE_PROTECTION
Definition: ac_adapter.h:23
const uint32_t FAN_AUTO
static bool is_custom_midea_preset(MideaPreset preset)
Definition: ac_adapter.cpp:152
static ClimatePreset to_climate_preset(MideaPreset preset)
Definition: ac_adapter.cpp:139
static ClimateSwingMode to_climate_swing_mode(MideaSwingMode mode)
Definition: ac_adapter.cpp:49
static MideaSwingMode to_midea_swing_mode(ClimateSwingMode mode)
Definition: ac_adapter.cpp:62
static MideaMode to_midea_mode(ClimateMode mode)
Definition: ac_adapter.cpp:32
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
static ClimateMode to_climate_mode(MideaMode mode)
Definition: ac_adapter.cpp:15
dudanov::midea::ac::SwingMode MideaSwingMode
Definition: ac_adapter.h:16
dudanov::midea::ac::Preset MideaPreset
Definition: ac_adapter.h:18
void add_supported_mode(ClimateMode mode)
static const std::string SILENT
Definition: ac_adapter.h:24
ClimatePreset preset
Definition: climate.h:578
dudanov::midea::ac::FanMode MideaFanMode
Definition: ac_adapter.h:17
static MideaFanMode to_midea_fan_mode(ClimateFanMode fan_mode)
Definition: ac_adapter.cpp:75