mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 03:18:26 +00:00
async++, small powerstrip improvements (#46)
* async++, small powerstrip improvements * use asyncclick instead of click, allows defining the commands with async def to avoid manual eventloop/asyncio.run handling * improve powerstrip support: * new powerstrip api: turn_{on,off}_by_{name,index} methods * cli: fix on/off for powerstrip using the new apis * add missing update()s for cli's hsv, led, temperature (fixes #43) * prettyprint the received payloads when debug mode in use * cli: debug mode can be activated now with '-d' * update requirements_test.txt * remove outdated click-datetime, replace click with asyncclick * debug is a flag * make smartstripplug to inherit the sysinfo from its parent, allows for simple access of general plug properties * proper bound checking for index accesses, allow controlling the plug at index 0 * remove the mess of turn_{on,off}_by_{name,index}, get_plug_by_{name,index} are enough. * adapt cli to use that * allow changing the alias per index * use f-strings consistently everywhere in the cli * add tests for get_plug_by_{index,name}
This commit is contained in:
@@ -92,13 +92,12 @@ def dev(request):
|
||||
Provides a device (given --ip) or parametrized fixture for the supported devices.
|
||||
The initial update is called automatically before returning the device.
|
||||
"""
|
||||
loop = asyncio.get_event_loop()
|
||||
file = request.param
|
||||
|
||||
ip = request.config.getoption("--ip")
|
||||
if ip:
|
||||
d = loop.run_until_complete(Discover.discover_single(ip))
|
||||
loop.run_until_complete(d.update())
|
||||
d = asyncio.run(Discover.discover_single(ip))
|
||||
asyncio.run(d.update())
|
||||
print(d.model)
|
||||
if d.model in file:
|
||||
return d
|
||||
@@ -125,7 +124,7 @@ def dev(request):
|
||||
model = basename(file)
|
||||
p = device_for_file(model)(host="123.123.123.123")
|
||||
p.protocol = FakeTransportProtocol(sysinfo)
|
||||
loop.run_until_complete(p.update())
|
||||
asyncio.run(p.update())
|
||||
yield p
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user