tasmota dht11 sensor, same graph colors, legend outside
[vaillant-thermostat] / temp3.sh
index 99b4a06..e171b3a 100755 (executable)
--- a/temp3.sh
+++ b/temp3.sh
@@ -31,11 +31,22 @@ __SHELL__
 influx_rtl() {
        file=$1
        shift;
-       rids=`echo $* | sed -e 's/\([0-9][0-9]*\)/ or "id" = '"'"'\1'"'"'/g' -e 's/^ or/ AND /'`
+       rids=`echo $* | sed -e 's/\([0-9][0-9]*\)/ or id = '"'"'\1'"'"'/g' -e 's/^ or/ AND /'`
 
 #      echo "# $topic [$rids] -> $file"
        cat <<__SHELL__ >> /dev/shm/curl
-curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"temperature_C\",\"humidity\" FROM \"mqtt_rtl_433\" WHERE time > now() - $INTERVAL and model="Prologue-TH" $rids" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
+curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"temperature_C\",\"humidity\" FROM \"mqtt_rtl_433\" WHERE time > now() - $INTERVAL and model='Prologue-TH' $rids" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
+__SHELL__
+}
+
+influx_tele() {
+       topic=$1
+       t_col=$2
+       h_col=$3
+       file=$4
+
+       cat <<__SHELL__ >> /dev/shm/curl
+curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"$t_col\",\"$h_col\" FROM \"mqtt_tele_sensor\" WHERE time > now() - $INTERVAL and topic='$topic'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
 __SHELL__
 }
 
@@ -43,16 +54,20 @@ influx_mqtt 'stat/boiler/DS18B20/temperature'       'DS18B20-t'
 influx_mqtt    'stat/boiler/DHT22/temperature'         'DHT22-t'
 influx_mqtt    'stat/boiler/DHT22/humidity'            'DHT22-h'
 
+influx_tele    'tele/ir/SENSOR' 'AM2301_Temperature' 'AM2301_Humidity' 'ir-dht22-t-h'
+influx_tele    'tele/dht11-ir-hdmi/SENSOR' 'DHT11_Temperature' 'DHT11_Humidity' 'stol-dht11-t-h'
+
 influx_mqtt    'stat/boiler/d'                         'boiler-d'
 
-influx_rtl     'vani-t-h' 40 0
-influx_rtl     'kutija-t-h' 95
-influx_rtl     'kupaona-t-h' 125 148
-influx_rtl     'kuhinja-t-h' 175 239
+influx_rtl     'vani-t-h' 0 165
+influx_rtl     'kutija-t-h' 95 90 82
+influx_rtl     'kupaona-t-h' 125 148 133
+influx_rtl     'kuhinja-t-h' 239 83
 influx_rtl     'soba-t-h' 59
 
 cat /dev/shm/curl | parallel
 
+echo "parallel over" >/dev/stderr
 
 GRAY=`echo $QUERY_STRING | grep -i gray | wc -l`