2020-05-27 14:55:18 +00:00
|
|
|
from kasa import DeviceType
|
|
|
|
|
2024-03-01 18:32:45 +00:00
|
|
|
from .conftest import plug_iot, plug_smart, switch_smart, wallswitch_iot
|
2024-01-29 19:26:39 +00:00
|
|
|
from .test_smartdevice import SYSINFO_SCHEMA
|
|
|
|
|
|
|
|
# these schemas should go to the mainlib as
|
|
|
|
# they can be useful when adding support for new features/devices
|
|
|
|
# as well as to check that faked devices are operating properly.
|
2020-05-27 14:55:18 +00:00
|
|
|
|
|
|
|
|
2024-03-01 18:32:45 +00:00
|
|
|
@plug_iot
|
2020-05-27 14:55:18 +00:00
|
|
|
async def test_plug_sysinfo(dev):
|
|
|
|
assert dev.sys_info is not None
|
2024-01-29 19:26:39 +00:00
|
|
|
SYSINFO_SCHEMA(dev.sys_info)
|
2020-05-27 14:55:18 +00:00
|
|
|
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.Plug or dev.device_type == DeviceType.Strip
|
|
|
|
assert dev.is_plug or dev.is_strip
|
|
|
|
|
|
|
|
|
2024-03-01 18:32:45 +00:00
|
|
|
@wallswitch_iot
|
|
|
|
async def test_switch_sysinfo(dev):
|
|
|
|
assert dev.sys_info is not None
|
|
|
|
SYSINFO_SCHEMA(dev.sys_info)
|
|
|
|
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.WallSwitch
|
|
|
|
assert dev.is_wallswitch
|
|
|
|
|
|
|
|
|
|
|
|
@plug_iot
|
|
|
|
async def test_plug_led(dev):
|
|
|
|
original = dev.led
|
|
|
|
|
|
|
|
await dev.set_led(False)
|
|
|
|
await dev.update()
|
|
|
|
assert not dev.led
|
|
|
|
|
|
|
|
await dev.set_led(True)
|
|
|
|
await dev.update()
|
|
|
|
assert dev.led
|
|
|
|
|
|
|
|
await dev.set_led(original)
|
|
|
|
|
|
|
|
|
|
|
|
@wallswitch_iot
|
|
|
|
async def test_switch_led(dev):
|
2020-05-27 14:55:18 +00:00
|
|
|
original = dev.led
|
|
|
|
|
|
|
|
await dev.set_led(False)
|
2021-09-19 21:45:48 +00:00
|
|
|
await dev.update()
|
2020-05-27 14:55:18 +00:00
|
|
|
assert not dev.led
|
|
|
|
|
|
|
|
await dev.set_led(True)
|
2021-09-19 21:45:48 +00:00
|
|
|
await dev.update()
|
2020-05-27 14:55:18 +00:00
|
|
|
assert dev.led
|
|
|
|
|
|
|
|
await dev.set_led(original)
|
2023-12-04 18:50:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
@plug_smart
|
|
|
|
async def test_plug_device_info(dev):
|
|
|
|
assert dev._info is not None
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert dev.device_type == DeviceType.Plug or dev.device_type == DeviceType.Strip
|
2024-03-01 18:32:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@switch_smart
|
|
|
|
async def test_switch_device_info(dev):
|
|
|
|
assert dev._info is not None
|
|
|
|
assert dev.model is not None
|
|
|
|
|
|
|
|
assert (
|
|
|
|
dev.device_type == DeviceType.WallSwitch or dev.device_type == DeviceType.Dimmer
|
|
|
|
)
|