,"/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
-#!/bin/sh -x
+#!/bin/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
+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
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
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=checkbox name="lines" value="1">
</form>
<img src="/temp2.png">
</body>