But:(($2 - $5) * 100.0)
tested, and working

A little typo I guess when you changed your script to use wget
Jozef
Moderator: Mattk
Code: Select all
#! /bin/sh
#
while :
do
# pull data filter the needed string
wget -O /dev/stdout "http://127.0.0.1/meteograph.cgi?text=all" | grep -E "actual_thb0_press_hpa|seqhour1_thb0_press_hpa" | gawk 'BEGIN {FS="_"} {print $4,$6}' | tr -s '\n' ' ' | gawk 'BEGIN {FS=" "} {printf "data9 %d\n", lround (($2 - $5) * 100.0) }'
# make sure output gets flushed
sync
# wait 900 seconds for next read
sleep 900
done
I've got no idea what's wrong in my configuration...wfpost wrote:boris sample is working with my meteohub.
the sleep value can´t be the culprit, I guess
30s is not a reasonable polling value anyway, because the website updates the temps every 20-30 minutes
What error do you get?
Code: Select all
#! /bin/sh
#
while :
do
# pull data from website and filter the needed string
wget -O /dev/stdout "http://www.meteoschweiz.admin.ch/web/de/wetter/aktuelles_wetter.par0005.sub0025.html" 2>/dev/null | grep "___BEZ" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "thb9 0 0 0 0 0 %d\n", lround ($1 * 10.0)}'
# make sure output gets flushed
sync
sleep 120
done
Code: Select all
meteohub:/home/meteohub# dir -l plugin*.sh
-rwxr-xr-x 1 root root 412 May 21 22:14 plugin_data19_press_delta3h.sh
-rwxr-xr-x 1 root root 392 May 8 22:25 plugin_t9_sylt_ost.sh
-rwxr-xr-x 1 root root 674 May 21 22:10 plugin_thb9_BEZ.sh
meteohub:/home/meteohub#
Code: Select all
logger (21.05.2011 22:50:31): unexpected 0 bytes delivered from weather station 2 (Plug-in)
logger (21.05.2011 22:50:31): disconnect station 2 (Plug-in).
logger (21.05.2011 22:50:31): unexpected 0 bytes delivered from weather station 3 (Plug-in)
logger (21.05.2011 22:50:31): disconnect station 3 (Plug-in).
logger (21.05.2011 22:50:31): unexpected 0 bytes delivered from weather station 4 (Plug-in)
logger (21.05.2011 22:50:31): disconnect station 4 (Plug-in).
Code: Select all
plugin_t9_sylt_ost.sh
Code: Select all
/home/meteohub/plugin_t9_sylt_ost.sh
Code: Select all
#! /bin/sh
#
while :
do
# pull data from website and filter the needed string
wget -O /dev/stdout "http://www.meteoschweiz.admin.ch/web/de/wetter/aktuelles_wetter.par0005.sub0025.html" 2>/dev/null | grep "___BEZ" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "thb9 0 0 0 %d 0 %d\n", lround ($1*10.0), lround ($1*10.0)}'
# make sure output gets flushed
sync
sleep 120
done
Code: Select all
logger (21.05.2011 23:21:38): Bad thb9 sensor data, "pressure x10" (0) out of range [5000:12000]
Code: Select all
meteohub:/home/meteohub# wget -O /dev/stdout "http://www.meteoschweiz.admin.ch/web/de/wetter/aktuelles_wetter.par0005.sub0025.html" 2>/dev/null | grep "___BEZ" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "thb9 0 0 0 %d 0 %d\n", lround ($1*10.0), lround ($1*10.0)}'
thb9 0 0 0 10187 0 10187
Code: Select all
#! /bin/sh
#
while :
do
# pull data from website and filter the needed string
wget -O /dev/stdout "http://www.meteoschweiz.admin.ch/web/de/wetter/aktuelles_wetter.par0005.sub0025.html" 2>/dev/null | grep "___BEZ" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "thb9 0 0 %d\n", lround ($1*10.0)}'
# make sure output gets flushed
sync
# wait 15 minutes for next read
sleep 900
done
How would you arrange the wget command, if I have to collect the timestamp and the barodata with 2 different grep/gawk commands?admin wrote:yes, this is not formally documented, but when the line you transmit does start with a ":" then meteohub takes the number after that as a linux "time_t" typed date information (seconds since 1.1.1970).
Example ":1305913348 t9 123" gets interpreted as
Temp sensor #9 is reporting 12.3 °C at 2011-05-20 19:42:28 CEST.
Code: Select all
website=$(wget -O - http://www.mydomain.com/mysite.html)
Code: Select all
echo $website
Code: Select all
wget --user-agent="" 'http://deutsch.wunderground.com/global/stations/10866.html' --output-document=wua.html
lynx -dump wua.html >wua.txt
sed -n '/ Aktueller Zustand/,$p' <wua.txt >wua1.txt
sed -n '/°C/,$p' <wua1.txt >wua.txt
sed -n '/Sichtweite/,$p' <wua1.txt >wuasicht.tmp
sed 20q wuasicht.tmp >wuasicht.txt
sed 11q wua.txt >wua.tmp
mv wua.tmp wua.txt
cp wua.txt wom.txt
rm *.tmp
ZUSTAND=$(awk 'NR==3 { print $1,$2 }' wua.txt)
SICHTWEITE=$(awk 'NR==2 { print $1 }' wuasicht.txt)
SICHTWEITE=$SICHTWEITE' km'
Not a pipe based solution, but my workaround in such a situation is to create a meteohub html template that reports the data I want, then call that (e.g. wget) from the plugin or virtual sensor script.admin wrote:no, sorry.wfpost wrote:Can I feed stdout with two variables at once in a pipe?
Certainly.wfpost wrote:Can I create a virtual thbx sensor reading data from a file instead of doing it via a new plug-in station?
Code: Select all
#!/usr/bin/perl -w
use strict;
print "100 50 50 9990 9990 1\n"
What is the trigger for a virtual sensor script, please? When does such a script start and/or stop?skyewright wrote:The main difference between a virtual sensor script and a plugin script is that the plugin script runs continually using a loop with a 'sleep' or some such to control how often it reports but the virtual sensor script runs afresh each time the trigger happens. There is nothing to stop you having a virtual sensor script that totally ignores the data that meteohub provides on stdout.
The trigger is that another (real) sensor has just delivered a reading to Meteohub.Hathor27 wrote: What is the trigger for a virtual sensor script, please? When does such a script start and/or stop?