From 364bdd6d35e07b20ae2b3128aabba8f2a10bc590 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Tue, 2 Aug 2022 22:49:14 +0200
Subject: [PATCH] Add celsius temp metrics
---
opensprinkler_prometheus_exporter.py | 32 +++++++++++++++++-----------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/opensprinkler_prometheus_exporter.py b/opensprinkler_prometheus_exporter.py
index c100e26..caac69f 100755
--- a/opensprinkler_prometheus_exporter.py
+++ b/opensprinkler_prometheus_exporter.py
@@ -12,7 +12,6 @@ Author: varac@varac.net
Todo:
* Add celsius temp values
* Add units of measurement
- * What's wtdata.p ?
"""
import json
@@ -33,19 +32,22 @@ log = logging.getLogger(__name__)
wt_eto = Gauge('opensprinkler_wt_eto', 'Weather provider: ETo', ['type'])
wt_radiation = Gauge('opensprinkler_wt_radiation',
'Weather provider: radiation')
-wt_temp = Gauge('opensprinkler_wt_temp',
- 'Weather provider: Temperature (min/max)', ['type'])
+wt_temp_f = Gauge('opensprinkler_wt_temp_f',
+ 'Weather provider: Temperature (min/max), Fahrenheid', ['type'])
+wt_temp_c = Gauge('opensprinkler_wt_temp_c',
+ 'Weather provider: Temperature (min/max), Celsius', ['type'])
wt_hum = Gauge('opensprinkler_wt_hum',
- 'Weather provider: Humidity (min/max)', ['type'])
-wt_wind = Gauge('opensprinkler_wt_wind', 'Weather provider: wind speed')
-wt_p = Gauge('opensprinkler_wt_p', 'Weather provider: ?')
-sun = Gauge('opensprinkler_sunrise',
- 'Daytime of sunrise (mins) (sunrise/sunset)', ['type'])
+ 'Weather provider: Humidity (min/max), %', ['type'])
+wt_wind = Gauge('opensprinkler_wt_wind', 'Weather provider: Wind speed, m/h')
+wt_precip = Gauge('opensprinkler_wt_precip',
+ 'Weather provider: Precipation, mm')
+sun = Gauge('opensprinkler_sun',
+ 'Daytime of sunrise (sunrise/sunset), mins', ['type'])
last_weather_call = Gauge('opensprinkler_last_weather_call',
- 'Timestamp of the last weather call/query (epoch time) (request/response)',
+ 'Timestamp of the last weather call/query (request/response), epoch time',
['type'])
water_level = Gauge('opensprinkler_water_level',
- 'Water level (i.e. % Watering, 0 to 250)')
+ 'Water level (0 to 250), %')
station_open = Gauge('opensprinkler_station_open',
'Station status, 0=closed, 1=open', ['station'])
@@ -79,12 +81,16 @@ def main():
wtdata = j['settings']['wtdata']
wt_eto.labels(type='current').set(wtdata['eto'])
wt_radiation.set(wtdata['radiation'])
- wt_temp.labels(type='min').set(wtdata['minT'])
- wt_temp.labels(type='max').set(wtdata['maxT'])
+ wt_temp_f.labels(type='min').set(wtdata['minT'])
+ wt_temp_f.labels(type='max').set(wtdata['maxT'])
+ wt_temp_c.labels(type='min').set(
+ (wtdata['minT'] - 32) * 5.0/9.0)
+ wt_temp_c.labels(type='max').set(
+ (wtdata['maxT'] - 32) * 5.0/9.0)
wt_hum.labels(type='min').set(wtdata['minH'])
wt_hum.labels(type='max').set(wtdata['maxH'])
wt_wind.set(wtdata['wind'])
- wt_p.set(wtdata['p'])
+ wt_precip.set(wtdata['p'])
sun.labels(type='sunrise').set(j['settings']['sunrise'])
sun.labels(type='sunset').set(j['settings']['sunset'])
last_weather_call.labels(
--
GitLab