Smartstrip: return on_since state information only when the socket is on (#161)

* Smartstrip: return on_since state information only when the socket is on

Fixes #160

* add proper cli printout for hs300 child sockets

* iterate over range, not an integer
This commit is contained in:
Teemu R
2019-03-16 21:32:59 +01:00
committed by GitHub
parent 8046c96b54
commit 960ec6a346
3 changed files with 15 additions and 1 deletions

View File

@@ -129,6 +129,15 @@ def state(ctx, dev):
click.echo(click.style("Device state: %s" % "ON" if dev.is_on else "OFF",
fg="green" if dev.is_on else "red"))
if dev.num_children > 0:
is_on = dev.is_on()
aliases = dev.get_alias()
for child in range(dev.num_children):
click.echo(
click.style(" * %s state: %s" %
(aliases[child],
"ON" if is_on[child] else "OFF"),
fg="green" if is_on[child] else "red"))
click.echo("Host/IP: %s" % dev.host)
for k, v in dev.state_information.items():
click.echo("%s: %s" % (k, v))