Skip to content

Commit 621a14d

Browse files
joostlekfrenck
authored andcommitted
Fix fan AC mode in SmartThings AC (home-assistant#145064)
1 parent 4906e78 commit 621a14d

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

homeassistant/components/smartthings/climate.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"heat": HVACMode.HEAT,
6767
"heatClean": HVACMode.HEAT,
6868
"fanOnly": HVACMode.FAN_ONLY,
69+
"fan": HVACMode.FAN_ONLY,
6970
"wind": HVACMode.FAN_ONLY,
7071
}
7172
STATE_TO_AC_MODE = {
@@ -88,6 +89,7 @@
8889
}
8990

9091
WIND = "wind"
92+
FAN = "fan"
9193
WINDFREE = "windFree"
9294

9395
UNIT_MAP = {"C": UnitOfTemperature.CELSIUS, "F": UnitOfTemperature.FAHRENHEIT}
@@ -388,14 +390,15 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
388390
tasks.append(self.async_turn_on())
389391

390392
mode = STATE_TO_AC_MODE[hvac_mode]
391-
# If new hvac_mode is HVAC_MODE_FAN_ONLY and AirConditioner support "wind" mode the AirConditioner new mode has to be "wind"
392-
# The conversion make the mode change working
393-
# The conversion is made only for device that wrongly has capability "wind" instead "fan_only"
393+
# If new hvac_mode is HVAC_MODE_FAN_ONLY and AirConditioner support "wind" or "fan" mode the AirConditioner
394+
# new mode has to be "wind" or "fan"
394395
if hvac_mode == HVACMode.FAN_ONLY:
395-
if WIND in self.get_attribute_value(
396-
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
397-
):
398-
mode = WIND
396+
for fan_mode in (WIND, FAN):
397+
if fan_mode in self.get_attribute_value(
398+
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
399+
):
400+
mode = fan_mode
401+
break
399402

400403
tasks.append(
401404
self.execute_device_command(

tests/components/smartthings/fixtures/device_status/da_ac_rac_01001.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"timestamp": "2025-02-09T14:35:56.800Z"
3333
},
3434
"supportedAcModes": {
35-
"value": ["auto", "cool", "dry", "wind", "heat", "dryClean"],
35+
"value": ["auto", "cool", "dry", "fan", "heat", "dryClean"],
3636
"timestamp": "2025-02-09T15:42:13.444Z"
3737
},
3838
"airConditionerMode": {

tests/components/smartthings/test_climate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,19 @@ async def test_ac_set_hvac_mode_turns_on(
196196

197197

198198
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
199-
async def test_ac_set_hvac_mode_wind(
199+
@pytest.mark.parametrize("mode", ["fan", "wind"])
200+
async def test_ac_set_hvac_mode_fan(
200201
hass: HomeAssistant,
201202
devices: AsyncMock,
202203
mock_config_entry: MockConfigEntry,
204+
mode: str,
203205
) -> None:
204206
"""Test setting AC HVAC mode to wind if the device supports it."""
205207
set_attribute_value(
206208
devices,
207209
Capability.AIR_CONDITIONER_MODE,
208210
Attribute.SUPPORTED_AC_MODES,
209-
["auto", "cool", "dry", "heat", "wind"],
211+
["auto", "cool", "dry", "heat", mode],
210212
)
211213
set_attribute_value(devices, Capability.SWITCH, Attribute.SWITCH, "on")
212214

@@ -223,7 +225,7 @@ async def test_ac_set_hvac_mode_wind(
223225
Capability.AIR_CONDITIONER_MODE,
224226
Command.SET_AIR_CONDITIONER_MODE,
225227
MAIN,
226-
argument="wind",
228+
argument=mode,
227229
)
228230

229231

0 commit comments

Comments
 (0)