Change state_information to return feature values (#804)

This changes `state_information` to return the names and values of
all defined features.
It was originally a "temporary" hack to show some extra, device-specific
information in the cli tool, but now that we have device-defined
features we can leverage them.
This commit is contained in:
Teemu R
2024-03-26 19:28:39 +01:00
committed by GitHub
parent d63f43a230
commit 35dbda7049
13 changed files with 70 additions and 115 deletions

View File

@@ -609,16 +609,7 @@ async def state(ctx, dev: Device):
echo(f"\tMAC (rssi): {dev.mac} ({dev.rssi})")
echo(f"\tLocation: {dev.location}")
echo("\n\t[bold]== Device specific information ==[/bold]")
for info_name, info_data in dev.state_information.items():
if isinstance(info_data, list):
echo(f"\t{info_name}:")
for item in info_data:
echo(f"\t\t{item}")
else:
echo(f"\t{info_name}: {info_data}")
echo("\n\t[bold]== Features == [/bold]")
echo("\n\t[bold]== Device-specific information == [/bold]")
for id_, feature in dev.features.items():
echo(f"\t{feature.name} ({id_}): {feature.value}")