12static void set_sensor(Sensor *sensor,
float value) {
13 if (sensor !=
nullptr && (!sensor->has_state() || sensor->get_raw_state() != value))
14 sensor->publish_state(value);
17template<
typename T>
void update_property(T &property,
const T &value,
bool &flag) {
18 if (property != value) {
26 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK &&
27 this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) {
32 for (
const char *p : existing) {
39 std::vector<const char *> merged(existing.begin(), existing.end());
45 bool need_publish =
false;
76 dudanov::midea::ac::Control ctrl{};
77 auto target_temp_val =
call.get_target_temperature();
78 if (target_temp_val.has_value())
79 ctrl.targetTemp = *target_temp_val;
80 auto swing_mode_val =
call.get_swing_mode();
81 if (swing_mode_val.has_value())
83 auto mode_val =
call.get_mode();
84 if (mode_val.has_value())
86 auto preset_val =
call.get_preset();
87 if (preset_val.has_value()) {
89 }
else if (
call.has_custom_preset()) {
93 auto fan_mode_val =
call.get_fan_mode();
94 if (fan_mode_val.has_value()) {
96 }
else if (
call.has_custom_fan_mode()) {
100 this->
base_.control(ctrl);
118 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) {
133 " [x] Period: %" PRIu32
"ms\n"
134 " [x] Response timeout: %" PRIu32
"ms\n"
135 " [x] Request attempts: %d",
136 this->
base_.getPeriod(), this->base_.getTimeout(), this->base_.getNumAttempts());
137#ifdef USE_REMOTE_TRANSMITTER
140 if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) {
141 this->
base_.getCapabilities().dump();
142 }
else if (this->
base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_ERROR) {
144 "Failed to get 0xB5 capabilities report. Suggest to disable it in config and manually set your "
145 "appliance options.");
153#ifdef USE_REMOTE_TRANSMITTER
162 static_cast<uint8_t
>(esphome::clamp<long>(std::lroundf(
temperature), 0L,
static_cast<long>(UINT8_MAX)));
164 char temp_symbol = use_fahrenheit ?
'F' :
'C';
166 temp_symbol, temp_uint8, temp_symbol);
172 ESP_LOGW(
Constants::TAG,
"Action needs remote_transmitter component");
177#ifdef USE_REMOTE_TRANSMITTER
181 ESP_LOGW(
Constants::TAG,
"Action needs remote_transmitter component");
186 if (this->
base_.getCapabilities().supportLightControl()) {
187 this->
base_.displayToggle();
189#ifdef USE_REMOTE_TRANSMITTER
193 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)