Add Fan interface for SMART devices (#873)

Enables the Fan interface for devices supporting that component.
Currently the only device with a fan is the ks240 which implements it as
a child device. This PR adds a method `get_module` to search the child
device for modules if it is a WallSwitch device type.
This commit is contained in:
Steven B
2024-04-30 17:42:53 +01:00
committed by GitHub
parent 7db989e2ec
commit 16f17a7729
6 changed files with 124 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ from kasa.smart import SmartDevice
from .conftest import (
bulb_smart,
device_smart,
get_device_for_fixture_protocol,
)
@@ -121,6 +122,24 @@ async def test_update_module_queries(dev: SmartDevice, mocker: MockerFixture):
spies[device].assert_not_called()
async def test_get_modules(mocker):
"""Test get_modules for child and parent modules."""
dummy_device = await get_device_for_fixture_protocol(
"KS240(US)_1.0_1.0.5.json", "SMART"
)
module = dummy_device.get_module("CloudModule")
assert module
assert module._device == dummy_device
module = dummy_device.get_module("FanModule")
assert module
assert module._device != dummy_device
assert module._device._parent == dummy_device
module = dummy_device.get_module("DummyModule")
assert module is None
@bulb_smart
async def test_smartdevice_brightness(dev: SmartDevice):
"""Test brightness setter and getter."""