Skip to content

Commit 19c9424

Browse files
committed
Show a different use case
1 parent 8c05484 commit 19c9424

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

example.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
USERNAME = "username"
88
PASSWORD = "password"
9-
PIN = "12345678"
10-
9+
PIN = "000000"
10+
CONTROL_PANEL = "7e67sadfe35fgsdfg445d68b4fd4105d1be44d"
1111

1212
async def main():
1313
"""The main part of the example script."""
@@ -16,20 +16,31 @@ async def main():
1616
await client.connect()
1717
print("Is authenticated?", client.authorized)
1818

19-
devices = await client.list_devices()
19+
control_panels = await client.list_control_panels()
20+
21+
print("Available control panels:")
22+
pprint.pprint(client.control_panels)
2023

21-
print("Available devices:")
22-
pprint.pprint(devices)
24+
print()
25+
# Get all available control panels
26+
print("Show all available control panels")
27+
print("---------------------------------")
2328

29+
control_panels = {}
30+
for control_panel in control_panels:
31+
if control_panel["online"]:
32+
print("Device online?", bool(control_panel["online"]))
33+
print("Device ID: ", control_panel["hash"])
34+
print("Device name: ", control_panel["name"])
35+
print()
36+
2437
print()
25-
# Get all units
26-
units = {}
27-
for unit in devices:
28-
if unit["online"]:
29-
print("Device online?", bool(unit["online"]))
30-
print("Device ID:", unit["hash"])
31-
print("Availables units:")
32-
units = await client.get_units(unit["hash"], PIN)
38+
39+
# Limit to one control panel
40+
print("Show availables endpoints of one control panel:")
41+
control_panel = CONTROL_PANEL
42+
print("Control panel:", control_panel)
43+
units = await client.get_endpoints(control_panel, PIN)
3344

3445
print("Zones:")
3546
pprint.pprint(client.zones)
@@ -39,7 +50,8 @@ async def main():
3950
pprint.pprint(client.areas)
4051

4152
print()
42-
# Get the state of an entity
53+
# Get the state of single endpoints
54+
print("Show the state of a given endpoint:")
4355
entity = client.zones[2]
4456
print("Entity:", entity["nome"])
4557
state = await client.get_status(entity["endpointId"])

0 commit comments

Comments
 (0)