forked from bdraco/nexia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (54 loc) · 2.08 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python3
"""Nexia Climate Device Access"""
import argparse
import code
import readline
import rlcompleter
import aiohttp
from nexia.const import BRAND_NEXIA
from nexia.home import NexiaHome
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--username", type=str, help="Your Nexia username/email address.")
parser.add_argument("--password", type=str, help="Your Nexia password.")
parser.add_argument("--brand", type=str, help="Brand (nexia or asair or trane).")
args = parser.parse_args()
brand = args.brand or BRAND_NEXIA
if not args.username or not args.password:
parser.print_help()
exit()
session = aiohttp.ClientSession()
nexia_home = NexiaHome(session, username=args.username, password=args.password, brand=brand)
print("NexiaThermostat instance can be referenced using nt.<command>.")
print("List of available thermostats and zones:")
for _thermostat_id in nexia_home.get_thermostat_ids():
thermostat = nexia_home.get_thermostat_by_id(_thermostat_id)
_thermostat_name = thermostat.get_name()
_thermostat_model = thermostat.get_model()
_thermostat_compressor_speed = thermostat.get_current_compressor_speed()
print(
f'{_thermostat_id} - "{_thermostat_name}" ({_thermostat_model}) [{_thermostat_compressor_speed}]'
)
print(" Zones:")
for _zone_id in thermostat.get_zone_ids():
zone = thermostat.get_zone_by_id(_zone_id)
_zone_name = zone.get_name()
_zone_status = zone.get_status()
print(f' {_zone_id} - "{_zone_name}" ({_zone_status})')
del (
_thermostat_id,
_thermostat_model,
_thermostat_name,
_zone_name,
_zone_id,
args,
parser,
)
nexia_home.update()
variables = globals()
variables.update(locals())
readline.set_completer(rlcompleter.Completer(variables).complete)
readline.parse_and_bind("tab: complete")
code.InteractiveConsole(variables).interact()
if __name__ == '__main__':
main()