From 7fef54ba79b3d8025d97ce92a0e67b7428c84edc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 30 Oct 2025 10:26:11 -0500 Subject: [PATCH] preen --- esphome/components/thermostat/climate.py | 10 ++++++++-- tests/integration/test_climate_custom_modes.py | 13 +------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/esphome/components/thermostat/climate.py b/esphome/components/thermostat/climate.py index 7ba1ec8cee..2bab3aa236 100644 --- a/esphome/components/thermostat/climate.py +++ b/esphome/components/thermostat/climate.py @@ -1028,6 +1028,12 @@ async def to_code(config): if all_custom_preset_names: cg.add(var.set_custom_presets(all_custom_preset_names)) - # Set custom fan modes + # Set custom fan modes (filter out standard enum fan modes) if CONF_CUSTOM_FAN_MODES in config: - cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES])) + custom_fan_modes = [ + mode + for mode in config[CONF_CUSTOM_FAN_MODES] + if mode.upper() not in climate.CLIMATE_FAN_MODES + ] + if custom_fan_modes: + cg.add(var.set_custom_fan_modes(custom_fan_modes)) diff --git a/tests/integration/test_climate_custom_modes.py b/tests/integration/test_climate_custom_modes.py index bbb4dc3dfa..10d608df77 100644 --- a/tests/integration/test_climate_custom_modes.py +++ b/tests/integration/test_climate_custom_modes.py @@ -2,7 +2,7 @@ from __future__ import annotations -from aioesphomeapi import ClimateInfo +from aioesphomeapi import ClimateInfo, ClimatePreset import pytest from .types import APIClientConnectedFactory, RunCompiledFunction @@ -24,9 +24,6 @@ async def test_climate_custom_fan_modes_and_presets( test_climate = climate_infos[0] # Verify custom fan modes are exposed - assert hasattr(test_climate, "supported_custom_fan_modes"), ( - "Climate should have supported_custom_fan_modes" - ) custom_fan_modes = test_climate.supported_custom_fan_modes assert len(custom_fan_modes) == 3, ( f"Expected 3 custom fan modes, got {len(custom_fan_modes)}" @@ -38,19 +35,11 @@ async def test_climate_custom_fan_modes_and_presets( ) # Verify enum presets are exposed (from preset: config map) - assert hasattr(test_climate, "supported_presets"), ( - "Climate should have supported_presets" - ) - from aioesphomeapi import ClimatePreset - assert ClimatePreset.AWAY in test_climate.supported_presets, ( "Expected AWAY in enum presets" ) # Verify custom string presets are exposed (from custom_presets: config list) - assert hasattr(test_climate, "supported_custom_presets"), ( - "Climate should have supported_custom_presets" - ) custom_presets = test_climate.supported_custom_presets assert len(custom_presets) == 3, ( f"Expected 3 custom presets, got {len(custom_presets)}: {custom_presets}"