-
Notifications
You must be signed in to change notification settings - Fork 4
/
dump_buttons.py
35 lines (27 loc) · 1.17 KB
/
dump_buttons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Prints out the id, name, and labels of each button in the Vantage controller."""
import argparse
import asyncio
import contextlib
import logging
from aiovantage import Vantage
# Grab connection info from command line arguments
parser = argparse.ArgumentParser(description="aiovantage example")
parser.add_argument("host", help="hostname of Vantage controller")
parser.add_argument("--username", help="username for Vantage controller")
parser.add_argument("--password", help="password for Vantage controller")
parser.add_argument("--debug", help="enable debug logging", action="store_true")
args = parser.parse_args()
async def main() -> None:
"""Run code example."""
if args.debug:
logging.basicConfig(level=logging.DEBUG)
# Connect to the Vantage controller
async with Vantage(args.host, args.username, args.password) as vantage:
# Print out the id, name, and labels of each button
async for button in vantage.buttons:
print(
f"[{button.id}] name='{button.name}' "
f"text1='{button.text1}' text2='{button.text2}'"
)
with contextlib.suppress(KeyboardInterrupt):
asyncio.run(main())