FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Print units on child features and in feature command by sdb9696 · Pull Request #855 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 7 additions & 4 deletions kasa/cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,10 @@ async def state(ctx, dev: Device):
echo("\t[bold]== Children ==[/bold]")
for child in dev.children:
echo(f"\t* {child.alias} ({child.model}, {child.device_type})")
for feat in child.features.values():
for id_, feat in child.features.items():
try:
echo(f"\t\t{feat.name}: {feat.value}")
unit = f" {feat.unit}" if feat.unit else ""
echo(f"\t\t{feat.name} ({id_}): {feat.value}{unit}")
except Exception as ex:
echo(f"\t\t{feat.name}: got exception (%s)" % ex)
echo()
Expand Down Expand Up @@ -1173,7 +1174,8 @@ async def feature(dev: Device, child: str, name: str, value):
def _print_features(dev):
for name, feat in dev.features.items():
try:
echo(f"\t{feat.name} ({name}): {feat.value}")
unit = f" {feat.unit}" if feat.unit else ""
echo(f"\t{feat.name} ({name}): {feat.value}{unit}")
except Exception as ex:
echo(f"\t{feat.name} ({name}): [red]{ex}[/red]")

Expand All @@ -1194,7 +1196,8 @@ def _print_features(dev):
feat = dev.features[name]

if value is None:
echo(f"{feat.name} ({name}): {feat.value}")
unit = f" {feat.unit}" if feat.unit else ""
echo(f"{feat.name} ({name}): {feat.value}{unit}")
return feat.value

echo(f"Setting {name} to {value}")
Expand Down

Back | FazBrowse Home | New Git URL