diff --git a/esphome/components/climate/climate.cpp b/esphome/components/climate/climate.cpp index dc5b411eaf..80027ee377 100644 --- a/esphome/components/climate/climate.cpp +++ b/esphome/components/climate/climate.cpp @@ -299,17 +299,11 @@ const optional &ClimateCall::get_swing_mode() const { return t const optional &ClimateCall::get_preset() const { return this->preset_; } optional ClimateCall::get_custom_fan_mode() const { - if (this->custom_fan_mode_ != nullptr) { - return std::string(this->custom_fan_mode_); - } - return {}; + return this->custom_fan_mode_ != nullptr ? std::string(this->custom_fan_mode_) : optional{}; } optional ClimateCall::get_custom_preset() const { - if (this->custom_preset_ != nullptr) { - return std::string(this->custom_preset_); - } - return {}; + return this->custom_preset_ != nullptr ? std::string(this->custom_preset_) : optional{}; } ClimateCall &ClimateCall::set_target_temperature_high(optional target_temperature_high) {