add lines checkbox to graphs
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 5 Sep 2017 08:53:15 +0000 (10:53 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 5 Sep 2017 08:53:15 +0000 (10:53 +0200)
temp2.gnuplot
temp2.sh

index 0317274..a7b9212 100644 (file)
@@ -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"
 
 ,"/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
 
 
 set origin 0.0, 0.0
 
 
index a8049f8..5b93cfc 100755 (executable)
--- 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 
 
 # sudo apt-get install jq
 # ln -s `pwd`/temp2.sh /var/www/html/temp2.sh 
 INTERVAL=`echo $QUERY_STRING | grep -i 't=[0-9]*h' | sed 's/.*t=\([0-9]*h\).*/\1/'`
 test -z "$INTERVAL" && INTERVAL=48h
 
 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
 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/
 
 
 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
 
 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__
 <body>
        echo "Content-type: text/html\r\n\r\n"
        cat << __HTML__
 <body>
-<form method="get" action="/temp2.sh" style="position: fixed; top: 0; right: 0">
+<form method="get" action="/temp2.sh" style="position: fixed; top: 0; left: 0">
 <input type=submit name="t" value="48h">
 <input type=submit name="t" value="24h">
 <input type=submit name="t" value="6h">
 <input type=submit name="t" value="1h">
 <input type=submit name="t" value="48h">
 <input type=submit name="t" value="24h">
 <input type=submit name="t" value="6h">
 <input type=submit name="t" value="1h">
+<input type=checkbox name="lines" value="1">
 </form>
 <img src="/temp2.png">
 </body>
 </form>
 <img src="/temp2.png">
 </body>