This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
datapoints.py
73 lines (64 loc) · 2.39 KB
/
datapoints.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
import sys
import pprint
import random
import json
import xmlrpc.client
"""
Use this script to fetch the datapoints of the devices paired with your CCU.
Depending on the specified port different devices will be presented:
2000 -> BidCos-Wired
2001 -> BidCos-RF
2010 -> HmIP-RF
Availability of these ports may depend on the CCU version, and as of now,
Homegear has no HmIP support.
To use this script (on Linux with Python 3 installed) place it on the machines
filesystem, mark it executable (chmod 755 datapoints.py), and execute like this:
/path/to/file/datapoints.py http://ccu.ip.addr.ess:2001
This will print out all available details of your devices for you to analyze.
If you want to provide this data to someone else, append a filename (devices.json)
to the command above.
The raw JSON that's being saved isn't pretty to read, but can be imported and read
by capable applications.
Device-IDs, addresses etc. are being anonymized. So posting the results of this
script online shouldn't be an issue since no private data is leaked (unless I
forgot to overwrite something critical).
Note: this is a quick-and-dirty script with minor testing and no validation of
provided parameters. So as always, use at your own risk.
"""
args = sys.argv[1:]
if not args:
print("Usage: ./datapoints.py http://ccu.ip.addr.ess:2001 [outfile.json]")
sys.exit(1)
ccu = args[0]
if len(args) > 1:
outfile = args[1]
else:
outfile = False
proxy = xmlrpc.client.ServerProxy(ccu)
devices = proxy.listDevices()
for device in devices:
paramsets = {}
for i in range(len(device['PARAMSETS'])):
try:
paramsets[device['PARAMSETS'][i]] = proxy.getParamsetDescription(device['ADDRESS'], device['PARAMSETS'][i])
except Exception:
pass
if 'CHILDREN' in device:
for i in range(len(device['CHILDREN'])):
device['CHILDREN'][i] = device['CHILDREN'][i][-3:]
device['ADDRESS'] = device['ADDRESS'][-3:]
if 'PARENT' in device:
device['PARENT'] = device['PARENT'][-3:]
r = random.randint(0, 5000)
if 'PHYSICAL_ADDRESS' in device:
device['PHYSICAL_ADDRESS'] = device['PHYSICAL_ADDRESS'] + r
if 'RF_ADDRESS' in device:
device['RF_ADDRESS'] = device['RF_ADDRESS'] + r
device['PARAMSETS'] = paramsets
if not outfile:
pprint.pprint(devices)
else:
with open(outfile, 'w') as f:
f.write(json.dumps(devices))
sys.exit(0)