mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
cli: print model, https, and lv for discover list (#1339)
``` kasa --target 192.168.xx.xx discover list HOST MODEL DEVICE FAMILY ENCRYPT HTTPS LV ALIAS 192.168.xxx.xxx KP115(EU) IOT.SMARTPLUGSWITCH XOR 0 - Fridge 192.168.xxx.xxx L900-5 SMART.TAPOBULB KLAP 0 2 L900 192.168.xxx.xxx P115 SMART.TAPOPLUG AES 0 2 Nightdesk 192.168.xxx.xxx TC65 SMART.IPCAMERA AES 1 2 Tapo_TC65_B593 ``` Also handles `TimeoutError` and `Exception` during `update()` --------- Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
This commit is contained in:
@@ -123,14 +123,19 @@ async def list(ctx):
|
||||
async def print_discovered(dev: Device):
|
||||
cparams = dev.config.connection_type
|
||||
infostr = (
|
||||
f"{dev.host:<15} {cparams.device_family.value:<20} "
|
||||
f"{cparams.encryption_type.value:<7}"
|
||||
f"{dev.host:<15} {dev.model:<9} {cparams.device_family.value:<20} "
|
||||
f"{cparams.encryption_type.value:<7} {cparams.https:<5} "
|
||||
f"{cparams.login_version or '-':<3}"
|
||||
)
|
||||
async with sem:
|
||||
try:
|
||||
await dev.update()
|
||||
except AuthenticationError:
|
||||
echo(f"{infostr} - Authentication failed")
|
||||
except TimeoutError:
|
||||
echo(f"{infostr} - Timed out")
|
||||
except Exception as ex:
|
||||
echo(f"{infostr} - Error: {ex}")
|
||||
else:
|
||||
echo(f"{infostr} {dev.alias}")
|
||||
|
||||
@@ -138,7 +143,10 @@ async def list(ctx):
|
||||
if host := unsupported_exception.host:
|
||||
echo(f"{host:<15} UNSUPPORTED DEVICE")
|
||||
|
||||
echo(f"{'HOST':<15} {'DEVICE FAMILY':<20} {'ENCRYPT':<7} {'ALIAS'}")
|
||||
echo(
|
||||
f"{'HOST':<15} {'MODEL':<9} {'DEVICE FAMILY':<20} {'ENCRYPT':<7} "
|
||||
f"{'HTTPS':<5} {'LV':<3} {'ALIAS'}"
|
||||
)
|
||||
return await _discover(
|
||||
ctx,
|
||||
print_discovered=print_discovered,
|
||||
|
Reference in New Issue
Block a user