1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-28 16:12:24 +01:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-09-25 14:24:58 -05:00

View File

@@ -367,9 +367,11 @@ void Climate::save_state_() {
state.uses_custom_fan_mode = true;
const auto &supported = traits.get_supported_custom_fan_modes();
std::vector<std::string> vec{supported.begin(), supported.end()};
auto it = std::find(vec.begin(), vec.end(), custom_fan_mode);
if (it != vec.end()) {
state.custom_fan_mode = std::distance(vec.begin(), it);
for (size_t i = 0; i < vec.size(); i++) {
if (vec[i] == custom_fan_mode.value()) {
state.custom_fan_mode = i;
break;
}
}
}
if (traits.get_supports_presets() && preset.has_value()) {
@@ -380,10 +382,11 @@ void Climate::save_state_() {
state.uses_custom_preset = true;
const auto &supported = traits.get_supported_custom_presets();
std::vector<std::string> vec{supported.begin(), supported.end()};
auto it = std::find(vec.begin(), vec.end(), custom_preset);
// only set custom preset if value exists, otherwise leave it as is
if (it != vec.cend()) {
state.custom_preset = std::distance(vec.begin(), it);
for (size_t i = 0; i < vec.size(); i++) {
if (vec[i] == custom_preset.value()) {
state.custom_preset = i;
break;
}
}
}
if (traits.get_supports_swing_modes()) {