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