use server timezone to correct UTC timestamps from influx
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 8 Nov 2017 10:44:50 +0000 (11:44 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 8 Nov 2017 10:44:50 +0000 (11:44 +0100)
temp2.gnuplot
temp2.sh

index e785eb8..3112a1b 100644 (file)
@@ -46,26 +46,30 @@ print "using default mean and spread"
 min_t = t_mean - ( t_spread / 2 )
 max_t = t_mean + ( t_spread / 2 )
 
+if ( ! exists("tz_secs") ) {
+       tz_secs=7200
+}
+
 set ytics nomirror
 set y2tics
 
 plot \
- "/dev/shm/DHT22-temperature" using ($1+7200):($2 > min_t && $2 < max_t ? $2 : '') with dots title "DHT22 unutra" \
-,"/dev/shm/rtl_433-9-172-temperature" using ($1+7200):($2) with dots title "vani" \
-,"/dev/shm/rtl_433-9-75-temperature"  using ($1+7200):($2) with dots title "kupaona" \
-,"/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-183-temperature" using ($1+7200):($2) with dots title "soba" lt rgb "#808000"
+ "/dev/shm/DHT22-temperature" using ($1+tz_secs):($2 > min_t && $2 < max_t ? $2 : '') with dots title "DHT22 unutra" \
+,"/dev/shm/rtl_433-9-172-temperature" using ($1+tz_secs):($2) with dots title "vani" \
+,"/dev/shm/rtl_433-9-75-temperature"  using ($1+tz_secs):($2) with dots title "kupaona" \
+,"/dev/shm/rtl_433-9-141-temperature" using ($1+tz_secs):($2) with dots title "kuhinja" \
+,"/dev/shm/DS18B20-temperature" using ($1+tz_secs):($2 > min_t && $2 < max_t ? $2 : '') with dots title "DS18B20 unutra" \
+,"/dev/shm/rtl_433-183-temperature" using ($1+tz_secs):($2) with dots title "soba" lt rgb "#808000"
 
 
 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" \
-,"/dev/shm/rtl_433-183-temperature" using ($1+7200):($2) with lines title "soba" lt rgb "#808000"
+ "/dev/shm/DHT22-temperature" using ($1+tz_secs):($2 > min_t && $2 < max_t ? $2 : '') with lines title "DHT22 unutra" \
+,"/dev/shm/rtl_433-9-172-temperature" using ($1+tz_secs):($2) with lines title "vani" \
+,"/dev/shm/rtl_433-9-75-temperature"  using ($1+tz_secs):($2) with lines title "kupaona" \
+,"/dev/shm/rtl_433-9-141-temperature" using ($1+tz_secs):($2) with lines title "kuhinja" \
+,"/dev/shm/DS18B20-temperature" using ($1+tz_secs):($2 > min_t && $2 < max_t ? $2 : '') with lines title "DS18B20 unutra" \
+,"/dev/shm/rtl_433-183-temperature" using ($1+tz_secs):($2) with lines title "soba" lt rgb "#808000"
 }
 
 if ( gray == 1 ) {
@@ -78,9 +82,9 @@ min_h = h_mean - h_spread
 max_h = h_mean + h_spread
 
 plot \
- "/dev/shm/DHT22-humidity" using ($1+7200):($2 > min_h && $2 < max_h ? $2 : '') with dots title "DHT22 unutra" \
-,"/dev/shm/rtl_433-9-172-humidity" using ($1+7200):($2) with lines title "vani" \
-,"/dev/shm/rtl_433-9-75-humidity"  using ($1+7200):($2) with lines title "kupaona" \
-,"/dev/shm/rtl_433-9-141-humidity" using ($1+7200):($2) with lines title "kuhunja"
+ "/dev/shm/DHT22-humidity" using ($1+tz_secs):($2 > min_h && $2 < max_h ? $2 : '') with dots title "DHT22 unutra" \
+,"/dev/shm/rtl_433-9-172-humidity" using ($1+tz_secs):($2) with lines title "vani" \
+,"/dev/shm/rtl_433-9-75-humidity"  using ($1+tz_secs):($2) with lines title "kupaona" \
+,"/dev/shm/rtl_433-9-141-humidity" using ($1+tz_secs):($2) with lines title "kuhunja"
 
 unset multiplot
index 1d456e2..7a97415 100755 (executable)
--- a/temp2.sh
+++ b/temp2.sh
@@ -38,8 +38,10 @@ curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-url
 
 GRAY=`echo $QUERY_STRING | grep -i gray | wc -l`
 
+tz_secs=`date +%:z | cut -d: -f1 | sed -e 's/^+//' -e 's/$/ * 3600/' | bc`
+
 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` ; gray=$GRAY ; lines=$LINES ; interval=\"$INTERVAL\"" 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` ; gray=$GRAY ; lines=$LINES ; interval=\"$INTERVAL\" ; tz_secs=$tz_secs" temp2.gnuplot
 
 if [ "$GRAY" = 1 ] ; then
        convert /dev/shm/temp2.png -gravity center -extent 600x800 -colorspace Gray /dev/shm/temp2-gray.png