mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 19:38:02 +00:00
Add support for lightstrips (KL430) (#74)
* Preliminary support for light strips * Add color temperature range and cleanup, thanks to @darkoppressor * Use lightstrip instead of {led,light}strip consistently everywhere * The cli flag is now --lightstrip * add apidocs * Add fixture file for KL430 Signed-off-by: Kevin Wells <darkoppressor@gmail.com> * Add discovery support, expose effect and length of the strip * use set_light_state instead of transition_light_state * Add tests for lightstrip * add doctests * Add KL430 to supported devices in README Co-authored-by: Kevin Wells <darkoppressor@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import pytest # type: ignore # https://github.com/pytest-dev/pytest/issues/3342
|
||||
|
||||
from kasa import DeviceType, Discover, SmartDevice, SmartDeviceException
|
||||
|
||||
from .conftest import bulb, dimmer, plug, pytestmark, strip
|
||||
from .conftest import bulb, dimmer, lightstrip, plug, pytestmark, strip
|
||||
|
||||
|
||||
@plug
|
||||
@@ -16,8 +16,10 @@ async def test_type_detection_plug(dev: SmartDevice):
|
||||
@bulb
|
||||
async def test_type_detection_bulb(dev: SmartDevice):
|
||||
d = Discover._get_device_class(dev.protocol.discovery_data)("localhost")
|
||||
assert d.is_bulb
|
||||
assert d.device_type == DeviceType.Bulb
|
||||
# TODO: light_strip is a special case for now to force bulb tests on it
|
||||
if not d.is_light_strip:
|
||||
assert d.is_bulb
|
||||
assert d.device_type == DeviceType.Bulb
|
||||
|
||||
|
||||
@strip
|
||||
@@ -34,6 +36,13 @@ async def test_type_detection_dimmer(dev: SmartDevice):
|
||||
assert d.device_type == DeviceType.Dimmer
|
||||
|
||||
|
||||
@lightstrip
|
||||
async def test_type_detection_lightstrip(dev: SmartDevice):
|
||||
d = Discover._get_device_class(dev.protocol.discovery_data)("localhost")
|
||||
assert d.is_light_strip
|
||||
assert d.device_type == DeviceType.LightStrip
|
||||
|
||||
|
||||
async def test_type_unknown():
|
||||
invalid_info = {"system": {"get_sysinfo": {"type": "nosuchtype"}}}
|
||||
with pytest.raises(SmartDeviceException):
|
||||
|
Reference in New Issue
Block a user