aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-11-23 10:39:00 +0100
committerGuido Günther <agx@sigxcpu.org>2014-11-23 11:39:42 +0100
commit1ecd1ee0914beb1a2bee8dd5f93c059fbf317a7f (patch)
tree4f39682d1f395aa8597fc59bd584f60afbed9d1c
parentbf5b38f7915fc388a99bbccb4348b43a0ceb9336 (diff)
Fixup pellematic-pumps for newer firmware too
Tested with "Touch V2.03 20140723"
-rwxr-xr-xpellematic-pumps59
1 files changed, 34 insertions, 25 deletions
diff --git a/pellematic-pumps b/pellematic-pumps
index e79b381..1f8cc4b 100755
--- a/pellematic-pumps
+++ b/pellematic-pumps
@@ -24,28 +24,38 @@ import json
username = os.getenv('username', 'oekofen')
password = os.getenv('password', username)
debug = os.getenv('debug')
+url = os.getenv('url')
# The items we want to plot:
-items = ["CAPPL:LOCAL.L_hk[0].pumpe",
- "CAPPL:LOCAL.L_pu[0].pumpe",
- "CAPPL:FA[0].L_luefterdrehzahl",
- "CAPPL:FA[0].L_saugzugdrehzahl",
- ]
+items = {"CAPPL:LOCAL.L_hk[0].pumpe":
+ 'Heat Circuit Pump',
+ "CAPPL:LOCAL.L_pu[0].pumpe":
+ "Buffer Load Pump",
+ "CAPPL:FA[0].L_luefterdrehzahl":
+ 'Burner Fan Speed',
+ "CAPPL:FA[0].L_saugzugdrehzahl":
+ 'Flue Gas Fan Speed',
+ }
def canon(name):
return re.sub(r"[^a-zA-Z0-9_]", "_", name)
-def fixup_name(item):
+def get_name(item):
name = None
- if ".L_pu[" in item['name']:
- name = "Buffer Load Pump %d"
- elif ".L_hk[" in item['name']:
- name = "Heat Circuit Pump %d"
- if name:
- name = name % (int(item['name'].split('.')[-2][-2]) + 1)
+ if item['name'] in items:
+ if ".L_pu[" in item['name']:
+ name = "Buffer Load Pump %d"
+ elif ".L_hk[" in item['name']:
+ name = "Heat Circuit Pump %d"
+ if name:
+ return name % (int(item['name'].split('.')[-2][-2]) + 1)
+ else:
+ if item['shortText'] != '???':
+ return item['shortText']
+ else:
+ return items[item['name']]
else:
- name = item['shortText']
- return name
+ return None
def percent_val(item):
if item['unitText'] == '%':
@@ -59,12 +69,11 @@ graph_vlabel Pump power in percent
graph_category Heating
graph_info This graph shows the pumping power of the different pumps
"""
-
draw = "AREA"
out = fetch_raw(url)
for item in out:
- if item['name'] in items:
- name = fixup_name(item)
+ name = get_name(item)
+ if name:
print "%s.label %s" % (canon(name), name)
print "%s.type GAUGE" % canon(name)
thickness = 1 if name.endswith('soll') else 2
@@ -97,7 +106,7 @@ def fetch_raw(url):
}
# The items to fetch are passed as simple json string
- payload = json.dumps(items)
+ payload = json.dumps(items.keys())
r = requests.post(url,
data=payload,
params=params,
@@ -114,20 +123,20 @@ def fetch_raw(url):
return ret
+
def fetch_values(url):
out = fetch_raw(url)
for item in out:
- if item['name'] in items:
- name = canon(fixup_name(item))
- print "%s.value %s" % (name, percent_val(item))
+ name = get_name(item)
+ if name:
+ cname = canon(name)
+ print "%s.value %s" % (cname, percent_val(item))
def main(args):
- target = os.getenv('address')
- if not target:
- print >>sys.stderr, "No ip address configured"
+ if not url:
+ print >>sys.stderr, "No url configured"
return 1
- url = 'http://%s' % target
if len(args) > 1:
if args[1] in [ 'autoconf', 'detect' ]:
try: