mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Make FAN_ON use the max duration rather than 15 min default (#46489)
This commit is contained in:
parent
b8f7bc12ee
commit
19f5b467b7
@ -75,6 +75,8 @@ FAN_MODE_MAP = {
|
|||||||
}
|
}
|
||||||
FAN_INV_MODE_MAP = {v: k for k, v in FAN_MODE_MAP.items()}
|
FAN_INV_MODE_MAP = {v: k for k, v in FAN_MODE_MAP.items()}
|
||||||
|
|
||||||
|
MAX_FAN_DURATION = 43200 # 15 hours is the max in the SDM API
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_sdm_entry(
|
async def async_setup_sdm_entry(
|
||||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
||||||
@ -322,4 +324,7 @@ class ThermostatEntity(ClimateEntity):
|
|||||||
if fan_mode not in self.fan_modes:
|
if fan_mode not in self.fan_modes:
|
||||||
raise ValueError(f"Unsupported fan_mode '{fan_mode}'")
|
raise ValueError(f"Unsupported fan_mode '{fan_mode}'")
|
||||||
trait = self._device.traits[FanTrait.NAME]
|
trait = self._device.traits[FanTrait.NAME]
|
||||||
await trait.set_timer(FAN_INV_MODE_MAP[fan_mode])
|
duration = None
|
||||||
|
if fan_mode != FAN_OFF:
|
||||||
|
duration = MAX_FAN_DURATION
|
||||||
|
await trait.set_timer(FAN_INV_MODE_MAP[fan_mode], duration=duration)
|
||||||
|
@ -819,6 +819,20 @@ async def test_thermostat_set_fan(hass, auth):
|
|||||||
"params": {"timerMode": "OFF"},
|
"params": {"timerMode": "OFF"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Turn on fan mode
|
||||||
|
await common.async_set_fan_mode(hass, FAN_ON)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert auth.method == "post"
|
||||||
|
assert auth.url == "some-device-id:executeCommand"
|
||||||
|
assert auth.json == {
|
||||||
|
"command": "sdm.devices.commands.Fan.SetTimer",
|
||||||
|
"params": {
|
||||||
|
"duration": "43200s",
|
||||||
|
"timerMode": "ON",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_thermostat_fan_empty(hass):
|
async def test_thermostat_fan_empty(hass):
|
||||||
"""Test a fan trait with an empty response."""
|
"""Test a fan trait with an empty response."""
|
||||||
@ -938,7 +952,7 @@ async def test_thermostat_set_hvac_fan_only(hass, auth):
|
|||||||
assert url == "some-device-id:executeCommand"
|
assert url == "some-device-id:executeCommand"
|
||||||
assert json == {
|
assert json == {
|
||||||
"command": "sdm.devices.commands.Fan.SetTimer",
|
"command": "sdm.devices.commands.Fan.SetTimer",
|
||||||
"params": {"timerMode": "ON"},
|
"params": {"duration": "43200s", "timerMode": "ON"},
|
||||||
}
|
}
|
||||||
(method, url, json, headers) = auth.captured_requests.pop(0)
|
(method, url, json, headers) = auth.captured_requests.pop(0)
|
||||||
assert method == "post"
|
assert method == "post"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user