14static void set_sensor(Sensor *sensor,
float value) {
15 if (sensor !=
nullptr && (!sensor->has_state() || sensor->get_raw_state() != value))
16 sensor->publish_state(value);
19template<
typename T>
void update_property(T &property,
const T &value,
bool &flag) {
20 if (property != value) {
28 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK &&
29 this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) {
34 for (
const char *p : existing) {
41 std::vector<const char *> merged(existing.begin(), existing.end());
47 bool need_publish =
false;
78 dudanov::midea::ac::Control ctrl{};
79 auto target_temp_val =
call.get_target_temperature();
80 if (target_temp_val.has_value())
81 ctrl.targetTemp = *target_temp_val;
82 auto swing_mode_val =
call.get_swing_mode();
83 if (swing_mode_val.has_value())
85 auto mode_val =
call.get_mode();
86 if (mode_val.has_value())
88 auto preset_val =
call.get_preset();
89 if (preset_val.has_value()) {
91 }
else if (
call.has_custom_preset()) {
95 auto fan_mode_val =
call.get_fan_mode();
96 if (fan_mode_val.has_value()) {
98 }
else if (
call.has_custom_fan_mode()) {
102 this->
base_.control(ctrl);
120 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) {
135 " [x] Period: %dms\n"
136 " [x] Response timeout: %dms\n"
137 " [x] Request attempts: %d",
138 this->
base_.getPeriod(), this->base_.getTimeout(), this->base_.getNumAttempts());
139#ifdef USE_REMOTE_TRANSMITTER
142 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) {
143 this->
base_.getCapabilities().dump();
144 }
else if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_ERROR) {
146 "Failed to get 0xB5 capabilities report. Suggest to disable it in config and manually set your "
147 "appliance options.");
155#ifdef USE_REMOTE_TRANSMITTER
164 static_cast<uint8_t
>(esphome::clamp<long>(std::lroundf(
temperature), 0L,
static_cast<long>(UINT8_MAX)));
166 char temp_symbol = use_fahrenheit ?
'F' :
'C';
168 temp_symbol, temp_uint8, temp_symbol);
174 ESP_LOGW(
Constants::TAG,
"Action needs remote_transmitter component");
179#ifdef USE_REMOTE_TRANSMITTER
183 ESP_LOGW(
Constants::TAG,
"Action needs remote_transmitter component");
188 if (this->
base_.getCapabilities().supportLightControl()) {
189 this->
base_.displayToggle();
191#ifdef USE_REMOTE_TRANSMITTER
195 ESP_LOGW(
Constants::TAG,
"Action needs remote_transmitter component");
constexpr bool empty() const
Check if the set is empty.
This class is used to encode all control actions on a climate device.
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
float target_temperature
The target temperature of the climate device.
void dump_traits_(const char *tag)
ClimateSwingMode swing_mode
The active swing mode of the climate device.
void set_supported_custom_presets(std::initializer_list< const char * > presets)
Set the supported custom presets (stored on Climate, referenced by ClimateTraits).
bool set_preset_(ClimatePreset preset)
Set preset. Reset custom preset. Return true if preset has been changed.
bool set_custom_preset_(const char *preset)
Set custom preset. Reset primary preset. Return true if preset has been changed.
bool set_fan_mode_(ClimateFanMode mode)
Set fan mode. Reset custom fan mode. Return true if fan mode has been changed.
float current_temperature
The current temperature of the climate device, as reported from the integration.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimatePreset > preset
The active preset of the climate device.
bool set_custom_fan_mode_(const char *mode)
Set custom fan mode. Reset primary fan mode. Return true if fan mode has been changed.
void set_visual_max_temperature(float visual_max_temperature)
void add_feature_flags(uint32_t feature_flags)
void add_supported_fan_mode(ClimateFanMode mode)
const ClimatePresetMask & get_supported_presets() const
const ClimateSwingModeMask & get_supported_swing_modes() const
void set_visual_temperature_step(float temperature_step)
void add_supported_preset(ClimatePreset preset)
void set_supported_presets(ClimatePresetMask presets)
void set_supported_swing_modes(ClimateSwingModeMask modes)
void set_visual_min_temperature(float visual_min_temperature)
void set_supported_modes(ClimateModeMask modes)
void add_supported_mode(ClimateMode mode)
const std::vector< const char * > & get_supported_custom_presets() const
const ClimateModeMask & get_supported_modes() const
void add_supported_swing_mode(ClimateSwingMode mode)
dudanov::midea::ac::AirConditioner base_
IrTransmitter transmitter_
void transmit(IrData &data)
ClimatePresetMask supported_presets_
void on_status_change() override
ClimateTraits traits() override
bool frost_protection_set_
void do_follow_me(float temperature, bool use_fahrenheit, bool beeper=false)
ClimateSwingModeMask supported_swing_modes_
void dump_config() override
Sensor * humidity_sensor_
void control(const ClimateCall &call) override
ClimateModeMask supported_modes_
static const char *const TAG
static const char *const FREEZE_PROTECTION
static ClimateFanMode to_climate_fan_mode(MideaFanMode fan_mode)
static ClimateSwingMode to_climate_swing_mode(MideaSwingMode mode)
static MideaSwingMode to_midea_swing_mode(ClimateSwingMode mode)
static MideaPreset to_midea_preset(ClimatePreset preset)
static const char * to_custom_climate_preset(MideaPreset preset)
static ClimateMode to_climate_mode(MideaMode mode)
static MideaFanMode to_midea_fan_mode(ClimateFanMode fan_mode)
static ClimatePreset to_climate_preset(MideaPreset preset)
static bool is_custom_midea_fan_mode(MideaFanMode fan_mode)
static const char * to_custom_climate_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)
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ 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.
void update_property(T &property, const T &value, bool &flag)
Providing packet encoding functions for exchanging data with a remote host.