From 00924190aee4c9e98d30cb9496a8484146e63087 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 11 Sep 2026 02:49:01 -0700 Subject: [PATCH] Allow Nest fan mode when HVAC mode is off (#181911) Co-authored-by: Home Assistant Developer --- homeassistant/components/nest/climate.py | 10 ----- tests/components/nest/test_climate.py | 56 ++++++++++++++++++------ 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/nest/climate.py b/homeassistant/components/nest/climate.py index da3489ac74b8..e664fa2f9ed1 100644 --- a/homeassistant/components/nest/climate.py +++ b/homeassistant/components/nest/climate.py @@ -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( diff --git a/tests/components/nest/test_climate.py b/tests/components/nest/test_climate.py index 09afe6ee814b..d9d411dd6ae9 100644 --- a/tests/components/nest/test_climate.py +++ b/tests/components/nest/test_climate.py @@ -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(