From ec508130d2c1f7542cb77a40298fdf7548716237 Mon Sep 17 00:00:00 2001 From: Leah Oswald Date: Sat, 8 Jan 2022 21:01:54 +0100 Subject: [PATCH] Add default mode 'auto' for tradfri starkvind air purifier on turn on (#63641) * add default mode 'auto' for tradfri starkvind air purifier on turn on This commits fixes the behaviour described in #60122 (purifier couldn't be started via toggle switch). It adds 'auto' as default mode/fallback for turning on the starkvind air purifier. This is now the same behaviour the original app provides. * Refactor code that set 'auto' as default value for tradfri starkvind on turn on --- homeassistant/components/tradfri/fan.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tradfri/fan.py b/homeassistant/components/tradfri/fan.py index 845d5e6d9c3..dab39f598f2 100644 --- a/homeassistant/components/tradfri/fan.py +++ b/homeassistant/components/tradfri/fan.py @@ -142,7 +142,7 @@ class TradfriAirPurifierFan(TradfriBaseDevice, FanEntity): preset_mode: str | None = None, **kwargs: Any, ) -> None: - """Turn on the fan.""" + """Turn on the fan. Auto-mode if no argument is given.""" if not self._device_control: return @@ -150,8 +150,8 @@ class TradfriAirPurifierFan(TradfriBaseDevice, FanEntity): await self._api(self._device_control.set_mode(_from_percentage(percentage))) return - if preset_mode: - await self.async_set_preset_mode(preset_mode) + preset_mode = preset_mode or ATTR_AUTO + await self.async_set_preset_mode(preset_mode) async def async_set_percentage(self, percentage: int) -> None: """Set the speed percentage of the fan."""