ESPHome 2025.5.0
Loading...
Searching...
No Matches
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
6namespace esphome {
7namespace midea {
8namespace ac {
9
10const char *const Constants::TAG = "midea";
11const std::string Constants::FREEZE_PROTECTION = "freeze protection";
12const std::string Constants::SILENT = "silent";
13const std::string Constants::TURBO = "turbo";
14
16 switch (mode) {
17 case MideaMode::MODE_AUTO:
19 case MideaMode::MODE_COOL:
21 case MideaMode::MODE_DRY:
23 case MideaMode::MODE_FAN_ONLY:
25 case MideaMode::MODE_HEAT:
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;
82 return MideaFanMode::FAN_HIGH;
83 default:
84 return MideaFanMode::FAN_AUTO;
85 }
86}
87
89 switch (mode) {
90 case MideaFanMode::FAN_LOW:
92 case MideaFanMode::FAN_MEDIUM:
94 case MideaFanMode::FAN_HIGH:
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
152bool Converters::is_custom_midea_preset(MideaPreset preset) { return preset == MideaPreset::PRESET_FREEZE_PROTECTION; }
153
155
156MideaPreset Converters::to_midea_preset(const std::string &preset) { return MideaPreset::PRESET_FREEZE_PROTECTION; }
157
158void 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())
173}
174
175} // namespace ac
176} // namespace midea
177} // namespace esphome
178
179#endif // USE_ARDUINO
BedjetMode mode
BedJet operating mode.
This class contains all static data for climate devices.
void add_supported_custom_preset(const std::string &preset)
void add_supported_preset(ClimatePreset preset)
void add_supported_mode(ClimateMode mode)
static const char *const TAG
Definition ac_adapter.h:22
static const std::string FREEZE_PROTECTION
Definition ac_adapter.h:23
static const std::string TURBO
Definition ac_adapter.h:25
static const std::string SILENT
Definition ac_adapter.h:24
static ClimateFanMode to_climate_fan_mode(MideaFanMode fan_mode)
static ClimateSwingMode to_climate_swing_mode(MideaSwingMode mode)
static const std::string & to_custom_climate_fan_mode(MideaFanMode fan_mode)
static MideaSwingMode to_midea_swing_mode(ClimateSwingMode mode)
static MideaPreset to_midea_preset(ClimatePreset preset)
static ClimateMode to_climate_mode(MideaMode mode)
static MideaFanMode to_midea_fan_mode(ClimateFanMode fan_mode)
static const std::string & to_custom_climate_preset(MideaPreset preset)
static ClimatePreset to_climate_preset(MideaPreset preset)
static bool is_custom_midea_fan_mode(MideaFanMode fan_mode)
static bool is_custom_midea_preset(MideaPreset preset)
static MideaMode to_midea_mode(ClimateMode mode)
static void to_climate_traits(ClimateTraits &traits, const dudanov::midea::ac::Capabilities &capabilities)
ClimatePreset preset
Definition climate.h:8
ClimatePreset
Enum for all preset modes.
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
ClimateSwingMode
Enum for all modes a climate swing can be in.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
dudanov::midea::ac::Mode MideaMode
Definition ac_adapter.h:15
dudanov::midea::ac::FanMode MideaFanMode
Definition ac_adapter.h:17
dudanov::midea::ac::Preset MideaPreset
Definition ac_adapter.h:18
dudanov::midea::ac::SwingMode MideaSwingMode
Definition ac_adapter.h:16
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7