From 60a303adb83eef202141a883ed5545fb7ddc88dd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 30 Oct 2025 20:10:36 -0500 Subject: [PATCH] simplify --- esphome/components/climate/climate.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/esphome/components/climate/climate.cpp b/esphome/components/climate/climate.cpp index f0f50973ab..36c407242a 100644 --- a/esphome/components/climate/climate.cpp +++ b/esphome/components/climate/climate.cpp @@ -593,29 +593,6 @@ void ClimateDeviceRestoreState::apply(Climate *climate) { climate->publish_state(); } -// Generic template to set one value while clearing its alternative (mutual exclusion) -// Handles both optional and const char* types automatically using compile-time type detection -template bool set_alternative(T1 &dst, T2 &alt, T3 src) { - bool is_changed = false; - - // Clear the alternative based on its type (pointer or optional) - if constexpr (std::is_pointer_v>) { - is_changed = (alt != nullptr); - alt = nullptr; - } else { - is_changed = alt.has_value(); - alt.reset(); - } - - // Set the destination value - if (is_changed || dst != src) { - dst = src; - is_changed = true; - } - - return is_changed; -} - bool Climate::set_fan_mode_(ClimateFanMode mode) { // Clear the custom fan mode (mutual exclusion) bool changed = this->custom_fan_mode_ != nullptr;