mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Allow Nest fan mode when HVAC mode is off (#181911)
Co-authored-by: Home Assistant Developer <hello@home-assistant.io>
This commit is contained in:
co-authored by
Home Assistant Developer
parent
4381f31d6f
commit
00924190ae
@@ -353,10 +353,6 @@ class ThermostatEntity(ClimateEntity):
|
||||
"""Set new target fan mode."""
|
||||
if fan_mode not in self.fan_modes:
|
||||
raise ValueError(f"Unsupported fan_mode '{fan_mode}'")
|
||||
if fan_mode == FAN_ON and self.hvac_mode == HVACMode.OFF:
|
||||
raise ValueError(
|
||||
"Cannot turn on fan, please set an HVAC mode (e.g. heat/cool) first"
|
||||
)
|
||||
trait = self._device.traits[FanTrait.NAME]
|
||||
duration = None
|
||||
if fan_mode != FAN_OFF:
|
||||
@@ -373,12 +369,6 @@ class ThermostatEntity(ClimateEntity):
|
||||
if not self.supported_features & ClimateEntityFeature.FAN_MODE:
|
||||
raise HomeAssistantError(f"Entity {self.entity_id} does not support fan")
|
||||
|
||||
if self.hvac_mode == HVACMode.OFF:
|
||||
raise HomeAssistantError(
|
||||
f"Cannot turn on fan for {self.entity_id},"
|
||||
" please set an HVAC mode (e.g. heat/cool) first"
|
||||
)
|
||||
|
||||
seconds = int(duration.total_seconds())
|
||||
if seconds <= 0 or seconds > MAX_FAN_DURATION:
|
||||
raise ValueError(
|
||||
|
||||
@@ -1155,16 +1155,25 @@ async def test_set_fan_timer_hvac_off(
|
||||
)
|
||||
await setup_platform()
|
||||
|
||||
with pytest.raises(HomeAssistantError, match="Cannot turn on fan"):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_fan_timer",
|
||||
{
|
||||
"entity_id": "climate.my_thermostat",
|
||||
"duration": {"minutes": 15},
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_fan_timer",
|
||||
{
|
||||
"entity_id": "climate.my_thermostat",
|
||||
"duration": {"minutes": 15},
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert auth.method == "post"
|
||||
assert auth.url == DEVICE_COMMAND
|
||||
assert auth.json == {
|
||||
"command": "sdm.devices.commands.Fan.SetTimer",
|
||||
"params": {
|
||||
"duration": "900s",
|
||||
"timerMode": "ON",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
async def test_set_fan_timer_no_fan(
|
||||
@@ -1313,9 +1322,30 @@ async def test_thermostat_set_fan_when_off(
|
||||
| ClimateEntityFeature.TURN_ON
|
||||
)
|
||||
|
||||
# Fan cannot be turned on when HVAC is off
|
||||
with pytest.raises(ValueError):
|
||||
await common.async_set_fan_mode(hass, FAN_ON, entity_id="climate.my_thermostat")
|
||||
# Turn off fan mode
|
||||
await common.async_set_fan_mode(hass, FAN_OFF, entity_id="climate.my_thermostat")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method == "post"
|
||||
assert auth.url == DEVICE_COMMAND
|
||||
assert auth.json == {
|
||||
"command": "sdm.devices.commands.Fan.SetTimer",
|
||||
"params": {"timerMode": "OFF"},
|
||||
}
|
||||
|
||||
# Turn on fan mode
|
||||
await common.async_set_fan_mode(hass, FAN_ON, entity_id="climate.my_thermostat")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert auth.method == "post"
|
||||
assert auth.url == DEVICE_COMMAND
|
||||
assert auth.json == {
|
||||
"command": "sdm.devices.commands.Fan.SetTimer",
|
||||
"params": {
|
||||
"duration": "43200s",
|
||||
"timerMode": "ON",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
async def test_thermostat_fan_empty(
|
||||
|
||||
Reference in New Issue
Block a user