Page 1 of 3
Plugin for Newbies
Posted: Thu May 05, 2011 10:03 pm
by Hathor27
Hi,
I'd like to plug additional weather-sensors to my meteohub. I read about in the manual, but can't get familiar with it.
- One sensor I can reach thru http, where I should extract a string from the web-page (e.g. position 435, substring of 6 characters)
- Another sensor comes from a HIOKI datalogger. Originally it has RS232. Meteohub has USB. Probably there is a RS232-USB-Convertor with a ready-made driver?
Can anybody help? Are there some sample plugins available or already made experiences? Thanks a lot in advance
Re: Plugin for Newbies
Posted: Thu May 19, 2011 11:31 pm
by Hathor27
Subject: Weather Station Plug-In example
admin wrote:This bash script is an example which pulls actual temperature data from a website (weather data of Sylt) and offers that to Meteohub:
Code: Select all
#! /bin/sh
#
while :
do
# pull data from website and filter the needed string
wget -O /dev/stdout "http://www.wetter.com/deutschland/sylt_ost/DE0010330.html" 2>/dev/null | grep "deg text_l temp_w" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "t9 %d\n", lround ($1 * 10.0)}'
# make sure output gets flushed
sync
# wait 30 seconds for next read
sleep 30
done
Thanks to admin for your sample. Now I found time to analyze and have one more questions:
Can I somehow send the already recognized timestamp (read from the url of the station) with the measured value for t9 to meteohub? This because I want to save the original timestamp, not the one getting data into meteohub.
Something like
???
Re: Plugin for Newbies
Posted: Fri May 20, 2011 7:44 pm
by admin
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.
Re: Plugin for Newbies
Posted: Fri May 20, 2011 10:25 pm
by wfpost
hi boris,
tried to create an 3h barochange plugin based on your example, but it only works on the shell.
Your code works with my meteohub, but mine, despite working on the console when started manually showing up with the correct print-out, but fails to come up in the GUI. What could be the reason?
Code: Select all
#! /bin/sh
#
while :
do
# pull data filter the needed string
nc localhost 5558 /dev/stdout 2>/dev/null | grep seqhour1_thb0_press_hpa | gawk 'BEGIN {FS="_"} {print $4,$7}' | gawk 'BEGIN {FS=" "} {printf "data9 %d\n", lround (($2 - $3) * 100.0) }'
# make sure output gets flushed
sync
# wait 300 seconds for next read
sleep 300
done
Re: Plugin for Newbies
Posted: Sat May 21, 2011 12:34 am
by admin
Do you do the sync thing to get things flushed to the listening stream?
Re: Plugin for Newbies
Posted: Sat May 21, 2011 1:09 am
by wfpost
yes, at least the sync command is in the shell script. The only thing I changed is the line where it reads the internal pressure value with nc.
When starting the shell script manually it shows the same bevaviour as your code:
It prints out the correct pair: sensor id + value. Exactly as with your example.
But for some reason it does not show up with the GUI.

Re: Plugin for Newbies
Posted: Sat May 21, 2011 9:20 am
by wfpost
seems it is nc, but why does it work when running manually as shell script?
logger (21.05.2011 08:57:23): connect station 3 (Plug-in via Plug-in).
logger (21.05.2011 08:57:23): error while doing write on socket 5558: Broken pipe
Re: Plugin for Newbies
Posted: Sat May 21, 2011 11:21 am
by admin
May be it needs a full qulified path. I don't know which environemnt is given the shell script when caled by Meteohub's logger.
Try "/bin/nc" instead of "nc" or check with "which nc" to find out where it is located on your system (may depend on used Meteohb platform).
Re: Plugin for Newbies
Posted: Sat May 21, 2011 11:30 am
by admin
another thought... Try using wget instead of nc:
wget -O - 127.0.0.1/meteograph.cgi?text=seqhour1_thb0_press_hpa 2>/dev/null
gets exactly the line of data you are looking for (no grep needed).
Re: Plugin for Newbies
Posted: Sat May 21, 2011 12:12 pm
by wfpost
tried already the full path, but same error.
the thing with wget works, but I changed my earlier version a bit,
because the seqhour isn´t correct to calculate the 3H barotrend; as start pressure this value is needed:
actual_thb0_press_hpa
Can I feed stdout with two variables at once in a pipe?
Or even better: How are the changes to have an intrinsic solution:
a 3h barochange variable built into meteohub?
Code: Select all
/bin/nc 192.168.1.112 5558 /dev/stdout 2>/dev/null | 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) }'
Re: Plugin for Newbies
Posted: Sat May 21, 2011 1:08 pm
by admin
wfpost wrote:Can I feed stdout with two variables at once in a pipe?
no, sorry.
Re: Plugin for Newbies
Posted: Sat May 21, 2011 1:14 pm
by wfpost
these lines work:
Code: Select all
#! /bin/sh
#
while :
do
# pull data filter the needed string
wget -O /dev/stdout "http://192.168.1.112/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
20110521120715 thb0 21.4 52 11.1 944.8 1018.6 2
20110521120755 th0 23.3 48 11.7
20110521120745 uv0 6.3
20110521120735 sol0 882
20110521120737 wind0 71 0.0 1.8 23.3
20110521120709 rain0 0.0 178.4 0.0
20110521120747 th1 21.2 53 11.2
20110521120749 t2 -22.9
20110521120750 t0 14.1
20110521120744 th2 23.0 45 10.4
20110521120804 th4 31.7 10 -3.7
20110521120724 th5 15.1 79 11.5
20110521120757 th3 26.9 44 13.6
20110521120801 data0 3.88
20110521120801 data1 45406.00
20110521120801 data3 0.91
20110521120801 data2 0.40
20110521120801 data4 0.01
20110521120801 data5 68.00
20110521120801 data6 3.00
20110521120801 data7 1.00
20110521120801 data8 0.20
20110521120634 data9 -1.60 <<<----- 3h pressure change in hPa
20110521120704 t7 23.6
Re: Plugin for Newbies
Posted: Sat May 21, 2011 1:21 pm
by Hathor27
Hi there,
wfpost wrote:hi boris,
tried to create an 3h barochange plugin based on your example, but it only works on the shell.
Your code works with my meteohub, but mine, despite working on the console when started manually showing up with the correct print-out, but fails to come up in the GUI. What could be the reason?
I noticed the same behaviour with
admins sample with wget...
admin wrote:This bash script is an example which pulls actual temperature data from a website (weather data of Sylt) and offers that to Meteohub:
Code: Select all
#! /bin/sh
#
while :
do
# pull data from website and filter the needed string
wget -O /dev/stdout "http://www.wetter.com/deutschland/sylt_ost/DE0010330.html" 2>/dev/null | grep "deg text_l temp_w" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "t9 %d\n", lround ($1 * 10.0)}'
# make sure output gets flushed
sync
# wait 30 seconds for next read
sleep 30
done
What is the difference? Just the
sleep 300 ?
Re: Plugin for Newbies
Posted: Sat May 21, 2011 2:03 pm
by wfpost
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?
Re: Plugin for Newbies
Posted: Sat May 21, 2011 2:04 pm
by admin
sleep value should be shorter than "data hold time" defined on "weather station" page for that particular station.