diff --git a/example-response-get-all.json b/example-response-get-all.json new file mode 100644 index 0000000000000000000000000000000000000000..c9bc37dbf8b7eaaf165f039ad5e79ae43ed0b6a3 --- /dev/null +++ b/example-response-get-all.json @@ -0,0 +1,219 @@ +{ + "settings": { + "devt": 1659438912, + "nbrd": 1, + "en": 1, + "sn1": 0, + "sn2": 0, + "rd": 0, + "rdst": 0, + "sunrise": 337, + "sunset": 1276, + "eip": 2728279633, + "lwc": 1659423573, + "lswc": 1659423573, + "lupt": 0, + "lrbtc": 99, + "lrun": [ + 1, + 1, + 2256, + 1659337117 + ], + "mac": "B8:27:EB:00:00:00", + "loc": "63.49257,08.12296", + "jsp": "https://ui.opensprinkler.com/js", + "wsp": "weather.opensprinkler.com", + "wto": { + "baseETo": 0.087, + "elevation": 20, + "pws": "", + "key": "" + }, + "ifkey": "", + "mqtt": {}, + "wtdata": { + "wp": "DS", + "eto": 0.153, + "radiation": 4.01, + "minT": 56, + "maxT": 75, + "minH": 48, + "maxH": 100, + "wind": 9.4, + "p": 0.04 + }, + "wterr": 0, + "sbits": [ + 0, + 0 + ], + "ps": [ + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ] + ] + }, + "programs": { + "nprogs": 1, + "nboards": 1, + "mnp": 40, + "mnst": 4, + "pnsize": 32, + "pd": [ + [ + 51, + 1, + 2, + [ + 16384, + 0, + 0, + 0 + ], + [ + 1500, + 1200, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "Alles" + ] + ] + }, + "options": { + "fwv": 219, + "tz": 56, + "hp0": 144, + "hp1": 31, + "hwv": 64, + "ext": 0, + "sdt": 0, + "mas": 0, + "mton": 0, + "mtof": 0, + "wl": 125, + "den": 1, + "ipas": 0, + "devid": 0, + "uwt": 3, + "ntp1": 0, + "ntp2": 0, + "ntp3": 0, + "ntp4": 0, + "lg": 1, + "mas2": 0, + "mton2": 0, + "mtof2": 0, + "fwm": 9, + "fpr0": 100, + "fpr1": 0, + "re": 0, + "sar": 0, + "ife": 0, + "sn1t": 0, + "sn1o": 1, + "sn2t": 0, + "sn2o": 1, + "sn1on": 0, + "sn1of": 0, + "sn2on": 0, + "sn2of": 0, + "wimod": 169, + "reset": 0, + "dexp": -1, + "mexp": 24, + "hwt": 255 + }, + "status": { + "sn": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "nstations": 8 + }, + "stations": { + "masop": [ + 255 + ], + "masop2": [ + 0 + ], + "ignore_rain": [ + 0 + ], + "ignore_sn1": [ + 0 + ], + "ignore_sn2": [ + 0 + ], + "stn_dis": [ + 252 + ], + "stn_seq": [ + 255 + ], + "stn_spe": [ + 0 + ], + "snames": [ + "1", + "2", + "S03", + "S04", + "S05", + "S06", + "S07", + "S08" + ], + "maxlen": 32 + } +} diff --git a/opensprinkler_prometheus_exporter.py b/opensprinkler_prometheus_exporter.py index 1565102d16bc2b1342ed4528730ea7b419f6d015..0d5b3c498ade77a47ddd0869e7e461c449d7b818 100755 --- a/opensprinkler_prometheus_exporter.py +++ b/opensprinkler_prometheus_exporter.py @@ -8,6 +8,11 @@ for Opensprinkler API documentation and https://github.com/OpenSprinkler/OpenSpr for the weather provider API (I couldn't find any weather provider API docs) Author: varac@varac.net + +Todo: + * Add celsius temp values + * Add units of measurement + * What's wtdata.p ? """ import json @@ -51,7 +56,7 @@ def main(): password = str(os.environ['OS_API_PW']) api_url = str(os.environ.get('OS_API_URL', 'http://localhost:8080')) - url = f'{api_url}/jc?pw={password}' + url = f'{api_url}/ja?pw={password}' port = int(os.environ.get('PORT', 3089)) log.info('Starting prometheus exporter on port %s', str(port)) log.debug(f'Using URL: {url}') @@ -64,8 +69,8 @@ def main(): if req.status_code == 200: j = json.loads(req.content) log.debug(f'Got a successful response: {j}') - wto = j['wto'] - wtdata = j['wtdata'] + wto = j['settings']['wto'] + wtdata = j['settings']['wtdata'] wt_base_eto.set(wto['baseETo']) wt_eto.set(wtdata['eto'])