From c330477af55a364bf2d00baeb0bddb58c42ecd8a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 23 Nov 2014 10:39:00 +0100 Subject: Fixup pellematic-switches for newer firmware too Tested with "Touch V2.03 20140723" --- pellematic-switches | 96 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 36 deletions(-) (limited to 'pellematic-switches') diff --git a/pellematic-switches b/pellematic-switches index fc5e8ab..0dcb01d 100755 --- a/pellematic-switches +++ b/pellematic-switches @@ -23,32 +23,53 @@ import json username = os.getenv('username', 'oekofen') password = os.getenv('password', username) debug = os.getenv('debug') +url = os.getenv('url') # The switches we want to plot (on/off 0/1 only): -items = ["CAPPL:FA[0].L_kap_sensor_raumentnahme", - "CAPPL:FA[0].L_kap_sensor_zwischenbehaelter", - # Burner require - "CAPPL:FA[0].L_br1", - # Brandschutzklappe - "CAPPL:FA[0].L_bsk_status", - # Motor suction turbine - "CAPPL:FA[0].ausgang_motor[0]", - "CAPPL:FA[0].ausgang_motor[1]", - "CAPPL:FA[0].ausgang_motor[2]", - "CAPPL:FA[0].ausgang_motor[3]", - "CAPPL:FA[0].ausgang_motor[4]", - "CAPPL:FA[0].ausgang_motor[5]", - "CAPPL:FA[0].ausgang_motor[8]", - # Pellet transport inside boiler - "CAPPL:FA[0].ausgang_motor[11]", - "CAPPL:FA[0].ausgang_stoermelderelais", - ] +items = { "CAPPL:FA[0].L_kap_sensor_raumentnahme": + 'Capacitive Sensor RA', + "CAPPL:FA[0].L_kap_sensor_zwischenbehaelter": + 'Capacitive Sensor Hopper', + "CAPPL:FA[0].L_br1": + 'Burner Require', + # Brandschutzklappe + "CAPPL:FA[0].L_bsk_status": + 'BSK Status', + # Motor suction turbine + "CAPPL:FA[0].ausgang_motor[0]": + 'Motor Suction Turbine', + #"CAPPL:FA[0].ausgang_motor[1]": + #'', + #"CAPPL:FA[0].ausgang_motor[2]": + #'', + #"CAPPL:FA[0].ausgang_motor[3]": + #'', + #"CAPPL:FA[0].ausgang_motor[4]": + #'', + #"CAPPL:FA[0].ausgang_motor[5]": + #'', + #"CAPPL:FA[0].ausgang_motor[8]": + #'', + # DHW (domestic hot water) pump switch? + #"CAPPL:FA[0].ausgang_motor[9]": + # Pellet transport inside boiler + "CAPPL:FA[0].ausgang_motor[11]": + 'Motor Delivery', + "CAPPL:FA[0].ausgang_stoermelderelais": + 'Relay Malfunction', + } def canon(name): return re.sub(r"[^a-zA-Z0-9_]", "_", name) -def fixup_name(item): - return item['shortText'] +def get_name(item): + if item['name'] in items.keys(): + if item['shortText'] != '???': + return item['shortText'] + else: + return items[item['name']] + else: + return None def print_config(url): print """graph_title Pellematic Switches @@ -56,17 +77,20 @@ graph_vlabel On (1) or Off (0) graph_category Heating graph_info This graph shows the values for different on/off switches """ - + names = [] draw = "AREA" out = fetch_raw(url) for item in out: - if item['name'] in items: - name = fixup_name(item) - print "%s.label %s" % (canon(name), name) - print "%s.type GAUGE" % canon(name) - print "%s.draw %s" % (canon(name), draw) - if draw == "AREA": - draw = "STACK" + name = get_name(item) + if name: + names.append(name) + + for name in sorted(names): + print "%s.label %s" % (canon(name), name) + print "%s.type GAUGE" % canon(name) + print "%s.draw %s" % (canon(name), draw) + if draw == "AREA": + draw = "STACK" if 'stoermelderelais' in item['name']: print "%s.warning 0.1" % canon(name) print "%s.critical 1" % canon(name) @@ -96,7 +120,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, @@ -113,20 +137,19 @@ 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, item['value']) + name = get_name(item) + if name: + print "%s.value %s" % (canon(name), item['value']) 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: @@ -140,6 +163,7 @@ def main(args): try: print_config(url) except Exception as e: + raise print >>sys.stderr, "Failed to fetch config: '%s'" % e return 1 return 0 -- cgit v1.2.3