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
This commit is contained in:
Leah Oswald 2022-01-08 21:01:54 +01:00 committed by GitHub
parent 8c51303332
commit ec508130d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""