Use direct device type discovery for devices (#106)

This is more efficient than enumerating all devices and checking the IP.
This commit is contained in:
K Henriksson
2018-01-14 10:10:53 -08:00
committed by Teemu R
parent 34347e59ae
commit a426488449
2 changed files with 54 additions and 24 deletions

View File

@@ -41,11 +41,7 @@ def cli(ctx, ip, debug, bulb, plug):
elif ip is not None:
if not bulb and not plug:
click.echo("No --bulb nor --plug given, discovering..")
devs = ctx.invoke(discover, discover_only=True)
for discovered_ip, discovered_dev in devs:
if discovered_ip == ip:
dev = discovered_dev
break
dev = Discover.discover_single(ip)
elif bulb:
dev = SmartBulb(ip)
elif plug: