Fix fan AC mode in SmartThings AC (#145064)

This commit is contained in:
Joost Lekkerkerker 2025-05-16 19:38:18 +02:00 committed by GitHub
parent 6b769ac263
commit be5685695e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 11 deletions

View File

@ -66,6 +66,7 @@ AC_MODE_TO_STATE = {
"heat": HVACMode.HEAT,
"heatClean": HVACMode.HEAT,
"fanOnly": HVACMode.FAN_ONLY,
"fan": HVACMode.FAN_ONLY,
"wind": HVACMode.FAN_ONLY,
}
STATE_TO_AC_MODE = {
@ -88,6 +89,7 @@ FAN_OSCILLATION_TO_SWING = {
}
WIND = "wind"
FAN = "fan"
WINDFREE = "windFree"
@ -387,14 +389,15 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
tasks.append(self.async_turn_on())
mode = STATE_TO_AC_MODE[hvac_mode]
# If new hvac_mode is HVAC_MODE_FAN_ONLY and AirConditioner support "wind" mode the AirConditioner new mode has to be "wind"
# The conversion make the mode change working
# The conversion is made only for device that wrongly has capability "wind" instead "fan_only"
# If new hvac_mode is HVAC_MODE_FAN_ONLY and AirConditioner support "wind" or "fan" mode the AirConditioner
# new mode has to be "wind" or "fan"
if hvac_mode == HVACMode.FAN_ONLY:
if WIND in self.get_attribute_value(
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
):
mode = WIND
for fan_mode in (WIND, FAN):
if fan_mode in self.get_attribute_value(
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
):
mode = fan_mode
break
tasks.append(
self.execute_device_command(

View File

@ -32,7 +32,7 @@
"timestamp": "2025-02-09T14:35:56.800Z"
},
"supportedAcModes": {
"value": ["auto", "cool", "dry", "wind", "heat", "dryClean"],
"value": ["auto", "cool", "dry", "fan", "heat", "dryClean"],
"timestamp": "2025-02-09T15:42:13.444Z"
},
"airConditionerMode": {

View File

@ -196,17 +196,19 @@ async def test_ac_set_hvac_mode_turns_on(
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
async def test_ac_set_hvac_mode_wind(
@pytest.mark.parametrize("mode", ["fan", "wind"])
async def test_ac_set_hvac_mode_fan(
hass: HomeAssistant,
devices: AsyncMock,
mock_config_entry: MockConfigEntry,
mode: str,
) -> None:
"""Test setting AC HVAC mode to wind if the device supports it."""
set_attribute_value(
devices,
Capability.AIR_CONDITIONER_MODE,
Attribute.SUPPORTED_AC_MODES,
["auto", "cool", "dry", "heat", "wind"],
["auto", "cool", "dry", "heat", mode],
)
set_attribute_value(devices, Capability.SWITCH, Attribute.SWITCH, "on")
@ -223,7 +225,7 @@ async def test_ac_set_hvac_mode_wind(
Capability.AIR_CONDITIONER_MODE,
Command.SET_AIR_CONDITIONER_MODE,
MAIN,
argument="wind",
argument=mode,
)