From: Dobrica Pavlinusic Date: Tue, 5 Sep 2017 08:53:15 +0000 (+0200) Subject: add lines checkbox to graphs X-Git-Url: http://git.rot13.org/?p=vaillant-thermostat;a=commitdiff_plain;h=291365eb1b01e9a359f791990cbca3cbbb03cc18 add lines checkbox to graphs --- diff --git a/temp2.gnuplot b/temp2.gnuplot index 0317274..a7b9212 100644 --- a/temp2.gnuplot +++ b/temp2.gnuplot @@ -45,6 +45,16 @@ plot \ ,"/dev/shm/rtl_433-9-141-temperature" using ($1+7200):($2) with dots title "kuhinja" \ ,"/dev/shm/DS18B20-temperature" using ($1+7200):($2 > min_t && $2 < max_t ? $2 : '') with dots title "DS18B20 unutra" + +if ( exists("lines") && lines == 1 ) { +plot \ + "/dev/shm/DHT22-temperature" using ($1+7200):($2 > min_t && $2 < max_t ? $2 : '') with lines title "DHT22 unutra" \ +,"/dev/shm/rtl_433-9-172-temperature" using ($1+7200):($2) with lines title "vani" \ +,"/dev/shm/rtl_433-9-75-temperature" using ($1+7200):($2) with lines title "kupaona" \ +,"/dev/shm/rtl_433-9-141-temperature" using ($1+7200):($2) with lines title "kuhinja" \ +,"/dev/shm/DS18B20-temperature" using ($1+7200):($2 > min_t && $2 < max_t ? $2 : '') with lines title "DS18B20 unutra" +} + set origin 0.0, 0.0 diff --git a/temp2.sh b/temp2.sh index a8049f8..5b93cfc 100755 --- a/temp2.sh +++ b/temp2.sh @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh # sudo apt-get install jq # ln -s `pwd`/temp2.sh /var/www/html/temp2.sh @@ -12,6 +12,10 @@ INTERVAL=`echo $QUERY_STRING | grep -i 't=[0-9]*h' | sed 's/.*t=\([0-9]*h\).*/\1/'` test -z "$INTERVAL" && INTERVAL=48h +LINES=0 +echo $QUERY_STRING | grep -i 'lines=' >/dev/null && LINES=1 + + curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"value\" FROM \"mqtt_consumer\" WHERE time > now() - $INTERVAL AND \"topic\"='stat/boiler/DS18B20/temperature'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DS18B20-temperature curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"value\" FROM \"mqtt_consumer\" WHERE time > now() - $INTERVAL AND \"topic\"='stat/boiler/DHT22/temperature'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DHT22-temperature curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"value\" FROM \"mqtt_consumer\" WHERE time > now() - $INTERVAL AND \"topic\"='stat/boiler/DHT22/humidity'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DHT22-humidity @@ -33,7 +37,7 @@ curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-url cd /home/pi/vaillant-thermostat/ -gnuplot -e "t_mean=`head -1 /dev/shm/temperature.mean.spread`;t_spread=`tail -1 /dev/shm/temperature.mean.spread`;h_mean=`head -1 /dev/shm/humidity.mean.spread` ; h_spread=`tail -1 /dev/shm/humidity.mean.spread`" temp2.gnuplot +gnuplot -e "t_mean=`head -1 /dev/shm/temperature.mean.spread`;t_spread=`tail -1 /dev/shm/temperature.mean.spread`;h_mean=`head -1 /dev/shm/humidity.mean.spread` ; h_spread=`tail -1 /dev/shm/humidity.mean.spread` ; lines=$LINES" temp2.gnuplot GRAY=`echo $QUERY_STRING | grep -i gray` if [ ! -z "$GRAY" ] ; then @@ -47,11 +51,12 @@ if echo $HTTP_USER_AGENT | grep Mozilla > /dev/null ; then echo "Content-type: text/html\r\n\r\n" cat << __HTML__ -
+ +