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:40 +0100
commitbf5b38f7915fc388a99bbccb4348b43a0ceb9336 (patch)
tree9e39dc08128b2c56a8d7fe1678de719f9ca17f87
parente08d2f6868f02a14e2feccfb8f8ed00e8751a0b5 (diff)
Fixup pellematic-draft for newer firmware too
Tested with "Touch V2.03 20140723"
-rwxr-xr-xpellematic-draft37
1 files changed, 27 insertions, 10 deletions
diff --git a/pellematic-draft b/pellematic-draft
index b3e7232..551b75b 100755
--- a/pellematic-draft
+++ b/pellematic-draft
@@ -34,9 +34,12 @@ 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:FA[0].L_unterdruck"]
+items = {"CAPPL:FA[0].L_unterdruck":
+ "Negative Draft",
+ }
def fixup(name):
return name
@@ -44,6 +47,22 @@ def fixup(name):
def canon(name):
return re.sub(r"[^a-zA-Z0-9_]", "_", name)
+def get_name(item):
+ """
+ Get the name of an item we care about. Use
+ the shortText if available. If not use a
+ hardcoded name.
+
+ If we don't know that item return None.
+ """
+ if item['name'] in items.keys():
+ if item['shortText'] != '???':
+ return fixup(item['shortText'])
+ else:
+ return items[item['name']]
+ else:
+ return None
+
def print_config(url):
print """graph_title Pellematic Negative Draft
graph_vlabel Temperature in Pa
@@ -52,8 +71,8 @@ graph_info This graph shows the negative pressure in the combustion chamber of a
out = fetch_raw(url)
for item in out:
- if item['name'] in items:
- name = fixup(item['shortText'])
+ name = get_name(item)
+ if name:
print "%s.label %s" % (canon(name), name)
print "%s.type GAUGE" % canon(name)
thickness = 1 if name.endswith(' Set') else 2
@@ -87,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,
@@ -107,18 +126,16 @@ def fetch_raw(url):
def fetch_values(url):
out = fetch_raw(url)
for item in out:
- if item['name'] in items:
- name = canon(fixup(item['shortText']))
+ name = get_name(item)
+ if name:
print "%s.value %.2f" % (name,
calc(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: