diff --git a/README.md b/README.md index 0870a76..02c5fe6 100644 --- a/README.md +++ b/README.md @@ -54,5 +54,5 @@ $ neohub_cli.py help # Shows all commands $ neohub_cli.py help set_time # Displays help for the set_time function $ neohub_cli.py --hub_ip=myneohub set_time "2021-01-31 15:43:00" # Specify times like this $ neohub_cli.py --hub_ip=myneohub set_lock 1234 "Living Room" # Name NeoStats like this. +$ neohub_cli.py --hub_ip=myneohub --hub_token=XXX get_system # Get system variables with websocket connection ``` - diff --git a/scripts/neohub_cli.py b/scripts/neohub_cli.py index e4604be..6c00cae 100755 --- a/scripts/neohub_cli.py +++ b/scripts/neohub_cli.py @@ -35,8 +35,9 @@ class NeoHubCLIArgumentError(Error): class NeoHubCLI(object): """A runner for neohub_cli operations.""" - def __init__(self, command, args, hub_ip=None, hub_port=4242): - self._hub = NeoHub(host=hub_ip, port=hub_port) + def __init__(self, command, args, hub_ip=None, hub_token=None): + hub_port = 4242 if hub_token is None else 4243 + self._hub = NeoHub(host=hub_ip, port=hub_port, token=hub_token) self._command = command self._args = args # live data cached from the neohub. We assume this data will remain current @@ -279,8 +280,7 @@ class NeoHubCLI(object): async def main(): argp = argparse.ArgumentParser(description='CLI to neohub devices') argp.add_argument('--hub_ip', help='IP address of NeoHub', default=None) - argp.add_argument( - '--hub_port', help='Port number of NeoHub to talk to', default=4242) + argp.add_argument('--hub_token', help='API token', default=None) argp.add_argument('--format', help='Output format', default='list') argp.add_argument('command', help='Command to issue') argp.add_argument('arg', help='Arguments to command', nargs='*') @@ -291,7 +291,8 @@ async def main(): args.command, args.arg, hub_ip=args.hub_ip, - hub_port=args.hub_port) + hub_token=args.hub_token, + ) m = await nhc.callable() if m: result = await m()