mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Fix fan AC mode in SmartThings AC (#145064)
This commit is contained in:
parent
6b769ac263
commit
be5685695e
@ -66,6 +66,7 @@ AC_MODE_TO_STATE = {
|
|||||||
"heat": HVACMode.HEAT,
|
"heat": HVACMode.HEAT,
|
||||||
"heatClean": HVACMode.HEAT,
|
"heatClean": HVACMode.HEAT,
|
||||||
"fanOnly": HVACMode.FAN_ONLY,
|
"fanOnly": HVACMode.FAN_ONLY,
|
||||||
|
"fan": HVACMode.FAN_ONLY,
|
||||||
"wind": HVACMode.FAN_ONLY,
|
"wind": HVACMode.FAN_ONLY,
|
||||||
}
|
}
|
||||||
STATE_TO_AC_MODE = {
|
STATE_TO_AC_MODE = {
|
||||||
@ -88,6 +89,7 @@ FAN_OSCILLATION_TO_SWING = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WIND = "wind"
|
WIND = "wind"
|
||||||
|
FAN = "fan"
|
||||||
WINDFREE = "windFree"
|
WINDFREE = "windFree"
|
||||||
|
|
||||||
|
|
||||||
@ -387,14 +389,15 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
|
|||||||
tasks.append(self.async_turn_on())
|
tasks.append(self.async_turn_on())
|
||||||
|
|
||||||
mode = STATE_TO_AC_MODE[hvac_mode]
|
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"
|
# If new hvac_mode is HVAC_MODE_FAN_ONLY and AirConditioner support "wind" or "fan" mode the AirConditioner
|
||||||
# The conversion make the mode change working
|
# new mode has to be "wind" or "fan"
|
||||||
# The conversion is made only for device that wrongly has capability "wind" instead "fan_only"
|
|
||||||
if hvac_mode == HVACMode.FAN_ONLY:
|
if hvac_mode == HVACMode.FAN_ONLY:
|
||||||
if WIND in self.get_attribute_value(
|
for fan_mode in (WIND, FAN):
|
||||||
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
|
if fan_mode in self.get_attribute_value(
|
||||||
):
|
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
|
||||||
mode = WIND
|
):
|
||||||
|
mode = fan_mode
|
||||||
|
break
|
||||||
|
|
||||||
tasks.append(
|
tasks.append(
|
||||||
self.execute_device_command(
|
self.execute_device_command(
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
"timestamp": "2025-02-09T14:35:56.800Z"
|
"timestamp": "2025-02-09T14:35:56.800Z"
|
||||||
},
|
},
|
||||||
"supportedAcModes": {
|
"supportedAcModes": {
|
||||||
"value": ["auto", "cool", "dry", "wind", "heat", "dryClean"],
|
"value": ["auto", "cool", "dry", "fan", "heat", "dryClean"],
|
||||||
"timestamp": "2025-02-09T15:42:13.444Z"
|
"timestamp": "2025-02-09T15:42:13.444Z"
|
||||||
},
|
},
|
||||||
"airConditionerMode": {
|
"airConditionerMode": {
|
||||||
|
@ -196,17 +196,19 @@ async def test_ac_set_hvac_mode_turns_on(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
|
@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,
|
hass: HomeAssistant,
|
||||||
devices: AsyncMock,
|
devices: AsyncMock,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mode: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting AC HVAC mode to wind if the device supports it."""
|
"""Test setting AC HVAC mode to wind if the device supports it."""
|
||||||
set_attribute_value(
|
set_attribute_value(
|
||||||
devices,
|
devices,
|
||||||
Capability.AIR_CONDITIONER_MODE,
|
Capability.AIR_CONDITIONER_MODE,
|
||||||
Attribute.SUPPORTED_AC_MODES,
|
Attribute.SUPPORTED_AC_MODES,
|
||||||
["auto", "cool", "dry", "heat", "wind"],
|
["auto", "cool", "dry", "heat", mode],
|
||||||
)
|
)
|
||||||
set_attribute_value(devices, Capability.SWITCH, Attribute.SWITCH, "on")
|
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,
|
Capability.AIR_CONDITIONER_MODE,
|
||||||
Command.SET_AIR_CONDITIONER_MODE,
|
Command.SET_AIR_CONDITIONER_MODE,
|
||||||
MAIN,
|
MAIN,
|
||||||
argument="wind",
|
argument=mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user