mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
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:
@@ -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."""
|
||||
|
Reference in New Issue
Block a user