dustbin_mode: add 'off' mode for cleaner downstream impl (#1488)

Adds a new artificial "Off" mode for dustbin_mode,
which will allow avoiding the need to expose both a toggle and a select
in homeassistant.

This changes the behavior of the existing mode selection, as it is not
anymore possible to change the mode without activating the auto
collection.

* Mode is Off, if auto collection has been disabled
* When setting mode to "Off", this will disable the auto collection
* When setting mode to anything else than "Off", the auto collection
will be automatically enabled.
This commit is contained in:
Teemu R.
2025-02-02 14:00:49 +01:00
committed by GitHub
parent 44c561b04d
commit 8259d28b12
2 changed files with 29 additions and 0 deletions

View File

@@ -60,6 +60,25 @@ async def test_dustbin_mode(dev: SmartDevice, mocker: MockerFixture):
await dustbin.set_mode("invalid")
@dustbin
async def test_dustbin_mode_off(dev: SmartDevice, mocker: MockerFixture):
"""Test dustbin_mode == Off."""
dustbin = next(get_parent_and_child_modules(dev, Module.Dustbin))
call = mocker.spy(dustbin, "call")
auto_collection = dustbin._device.features["dustbin_mode"]
await auto_collection.set_value(Mode.Off.name)
params = dustbin._settings.copy()
params["auto_dust_collection"] = False
call.assert_called_with("setDustCollectionInfo", params)
await dev.update()
assert dustbin.auto_collection is False
assert dustbin.mode is Mode.Off.name
@dustbin
async def test_autocollection(dev: SmartDevice, mocker: MockerFixture):
"""Test autocollection switch."""