-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
53 lines (43 loc) · 1.69 KB
/
cli.py
File metadata and controls
53 lines (43 loc) · 1.69 KB
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
#!/usr/bin/env python3
import sys
from neohub import NeoHub
def main():
if len(sys.argv) < 3:
print("Usage: python cli.py username password [device_name]")
sys.exit(1)
username = sys.argv[1]
password = sys.argv[2]
device_filter = sys.argv[3] if len(sys.argv) > 3 else None
# Create NeoHub client
client = NeoHub(username, password)
try:
# Login and get devices
print("Logging in...")
devices = client.login()
print(f"Found {len(devices)} devices")
# Filter devices if name provided
if device_filter:
devices = [d for d in devices if d.devicename == device_filter]
if not devices:
print(f"No device found with name: {device_filter}")
sys.exit(1)
# Process each device
for device in devices:
print(f"\nDevice: {device.devicename} (ID: {device.deviceid})")
print(f"Type: {device.type}")
print(f"Online: {device.online}")
if device.online:
# Get detailed data for online devices
data = client.get_data(device.deviceid)
# Print zone information
for zone in data['CACHE_VALUE']['live_info']['devices']:
print(f"\nZone: {zone.ZONE_NAME}")
print(f"Current temperature: {zone.ACTUAL_TEMP}")
print(f"Target temperature: {zone.SET_TEMP}")
print(f"Heating: {'On' if zone.HEAT_ON else 'Off'}")
print(f"Mode: {zone.HC_MODE}")
except Exception as e:
print(f"Error: {str(e)}")
sys.exit(1)
if __name__ == "__main__":
main()