+influx_tele() {
+ topic=$1
+ t_col=$2
+ h_col=$3
+ file=$4
+
+ cat <<__SHELL__ >> /dev/shm/curl
+curl -G 'http://10.60.0.92: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__
+}
+
+curl -G 'http://10.60.0.92:8086/query' --data-urlencode "db=rtl_433" --data-urlencode "q=SELECT time,id,temperature_C,humidity FROM \"Prologue-TH\" WHERE time > now() - $INTERVAL" -H "Accept: application/csv" --data-urlencode "epoch=s" \
+ | tee /dev/shm/rtl_433.th \
+ | awk -F, '{print $3" "$5" "$6 > "/dev/shm/id."$4 }'
+
+psql_subvision() {
+ to=$1
+ echo "select extract(epoch from time), temperature, humidity from s_1 where time > now() - interval '$INTERVAL' order by time" | \
+ ssh subvision psql -t -A eg5120 | sed 's/|/ /g' > /dev/shm/data.$to
+}
+
+
+rename_ids() {
+ to=$1
+ shift
+ while [ ! -z "$1" ] ; do
+ if [ -e /dev/shm/id.$1 ] ; then
+ cat /dev/shm/id.$1 > /dev/shm/data.$to
+ rm /dev/shm/id.$1
+ else
+ rm /dev/shm/data.$to
+ fi
+ shift
+ done
+}
+
+rename_ids 'vani-t-h' 156 # sunce
+rename_ids 'kutija-t-h' 138 # hlad
+#rename_ids 'kupaona-t-h' 78 15
+psql_subvision 'kupaona-t-h'
+rename_ids 'kuhinja-t-h' 144
+rename_ids 'soba-t-h' 251
+rename_ids 'hodnik-t-h' 234
+
+