forked from theosnel/python-xsense
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (25 loc) · 830 Bytes
/
Copy pathtest.py
File metadata and controls
32 lines (25 loc) · 830 Bytes
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
from contextlib import suppress
from xsense import XSense
from xsense.exceptions import APIFailure, NotFoundError
from xsense.utils import dump_environment, get_credentials
api = XSense()
api.init()
username, password = get_credentials()
api.login(username, password)
api.load_all()
for _, h in api.houses.items():
try:
api.get_house_state(h)
except NotFoundError:
print(f'could not retrieve status for {h.name}')
for _, s in h.stations.items():
try:
api.get_station_state(s)
api.get_state(s)
for _, d in s.devices.items():
with suppress(NotFoundError):
res = api.get_station_state(s)
res = api.get_state(s)
except APIFailure as e:
print(f'ERROR: {e}')
dump_environment(api)