Page 1 of 1

Upload to Twitter?

Posted: Sat Mar 19, 2011 4:24 pm
by WS Grave
Would it be possible to embed a function into Meteohub to send a small weather update to Twitter?

Re: Upload to Twitter?

Posted: Sat Mar 19, 2011 7:27 pm
by wfpost

Re: Upload to Twitter?

Posted: Tue Mar 22, 2011 11:12 am
by shinebar
I'm using twittermail and parts of your script, wfpost - thanks a lot.

And obviously, we're suffering the same problems:
honsolgen
09:30 ☛ leicht bewölkt |T: 4.1°C ▪ min -2.8° max 3.9° | 6 km/h - E | ⇑ 1036.1 hPa | ☂0.00 l
WetterQuickborn
#Wetter #Quickborn Temp Grad Celsius heute: 9.1 | 0.5 | 8.8 (akt|min|max) - Baro 1036.1 hpa konstant - Wind 1.2 bft SSW - Regen/24h 0.00 mm
The max/min temperatures are not recalculated before tweeting. So the actual temperature is higher / lower than the min max if it ist still rising / falling. Is there any way to force recalculation? Otherwise I'm thinking of editing the script in a manner like "if temp-max < temp-act than temp-max == temp-act fi" - that would do the trick without a big hazzle, but probably there is a clean way to manage this.

Danny

Edit: just decided to use the quick & dirty solution:

Code: Select all

if [ "$actual_wind0_speed_bft" = "0.00" ]; then actual_wind0_dir_en=; fi
if ( expr $last24h_th0_tempmin_c \> $actual_th0_temp_c >/dev/null ); then  last24h_th0_tempmin_c="$actual_th0_temp_c" ; fi
if ( expr $last24h_th0_tempmax_c \< $actual_th0_temp_c >/dev/null ); then  last24h_th0_tempmax_c="$actual_th0_temp_c" ; fi

Re: Upload to Twitter?

Posted: Tue Mar 22, 2011 8:17 pm
by wfpost
hi,

thanks for the hint. Wasn´t aware of it.
The day1 variables for max/min are not updated every minute it seems, more likely every half an hour of even every hour, which makes sense in way.

So, I need as well alter my script with your changes.

Thx,
Wolfgang

Re: Upload to Twitter?

Posted: Tue Mar 22, 2011 8:34 pm
by wfpost
BTW:
Your barotrend is wrong, because meteohubs barotrend variables have a bug, and do not reflect reasonable pressure changes.
That´s why meteohub shows for baro trend most of the time: steady
viewtopic.php?f=18&t=5651&p=8580&hilit= ... rend#p8580

Because of this, I do the barotrend calc with the shellscript as well
That works fine and is in line with the VP2 display and the VP2 algorithm --> Barometric Trend (3 hour)
(I do not use the slowly/rapidly definition, only the slowly values reflect a change in pressure with my approach, though it would be easy to alter this, if needed)

Image

Code: Select all

baro1=$(grep actual_thb0_press_hpa <sensordata.txt | awk 'NR==1 { print $2 }')
grep seqhour1_thb0_press_hpa <sensordata.txt | awk 'NR==1 { print $2 }' >baro.out
sed -i "s/_/ /g" baro.out
baro3=$(awk 'NR==1 { print $4 }' baro.out)
BAROVP=$(bc << EOF
$baro1-$baro3
EOF)

if (( $(bc <<< "$BAROVP >= -0.7") > 0 )); then BAROTREND="&#8660;"; fi
if (( $(bc <<< "$BAROVP >= 0.7") > 0 )); then BAROTREND="&#8657;"; fi
if (( $(bc <<< "$BAROVP <= -0.7") > 0 )); then BAROTREND="&#8659;"; fi

Re: Upload to Twitter?

Posted: Tue Mar 22, 2011 9:14 pm
by shinebar
wfpost wrote:BTW:
Your barotrend is wrong, because meteohubs barotrend variables have a bug, and do not reflect reasonable pressure changes.
That´s why meteohub shows for baro trend most of the time: steady
viewtopic.php?f=18&t=5651&p=8580&hilit= ... rend#p8580

Because of this, I do the barotrend calc with the shellscript as well
Thanks a lot! I noticed, that the trend was always (mh, well, 6x in a row) constant and planned to have a look on the code this evening - now I copy & pasted your code and can have a cold beer! :)

Re: Upload to Twitter?

Posted: Tue Mar 22, 2011 11:35 pm
by shinebar
wfpost wrote: So, I need as well alter my script with your changes.
But my script isn't working properly:

Code: Select all

meteohub:~# echo $last24h_th0_tempmax_c
14.9
meteohub:~# echo  $actual_th0_temp_c
5.5
meteohub:~# if ( expr $last24h_th0_tempmax_c \< $actual_th0_temp_c); then echo $last24h_th0_tempmax_c ist kleiner $actual_th0_temp_c; fi
1
14.9 ist kleiner 5.5
meteohub:~#  echo $last24h_th0_tempmin_c
0.5
meteohub:~#  if ( expr '$last24h_th0_tempmin_c' \> '$actual_th0_temp_c' >/dev/null ); then echo $last24h_th0_tempmin_c ist groesser $actual_th0_temp_c  ; fi
0.5 ist groesser 5.5

bc works much better:

Code: Select all

if [ "`echo "$last24h_th0_tempmin_c > $actual_th0_temp_c" | bc -l`" = "1" ] ; then  last24h_th0_tempmin_c="$actual_th0_temp_c" ; fi
if [ "`echo "$last24h_th0_tempmax_c < $actual_th0_temp_c" | bc -l`" = "1" ] ; then  last24h_th0_tempmax_c="$actual_th0_temp_c" ; fi

Re: Upload to Twitter?

Posted: Wed Mar 23, 2011 9:53 am
by wfpost
yep, because only bc does handle non-integers