Had my first crack at a perl script to read the data from my personal weather station and get Nab to speak the results. (i nicked some of the code from fridgeheads gaim plugin
)
code was messy its the 1st time Ive touched Perl and havent coded since my Uni days.
You can prob do the same for yourself, but download a METAR instead:
http://weather.noaa.gov/weather/metar.shtml
for example the one for Cardiff airport is here:
http://weather.noaa.gov/pub/data/forecasts/taf/stations/EGFF.TXT
should be easy enought to parse the file
For the ultimate geekness I've got my X10 HomeSeer server to launch my script with a keypress on my RF remote, so Nab says the weather on demand
script:
- Citation :
- #!/usr/bin/env perl
use LWP::UserAgent;
$serialno = "xxxxxxxxxxxx"; #serial
$token = "xxxxxxxxxxxxxxx"; #Token
$FILE="C:\\wdisplay\\logfiles\\scriptlog.txt"; #Weather Display Input File
$/=","; #Comma Delimited
open FILE or die "Can't open $FILE for read: $!\n";
@list=<FILE>;
$wind = @list[29]*1;
$gust = @list[30]*1;
$direction = @list[31]*1;
$hum = @list[33]*1;
$in_temp = int(((@list[34]-32)/9)*5);
$out_temp = int(((@list[35]-32)/9)*5);
$baro = int((@list[39]*1)*33.8639);
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1" . $ua->agent);
$url = "http://www.nabaztag.com/vl/FR/api.jsp?serial=$serialno&token=$token&ttlive=1&tts=outside temperature is $out_temp degrees, inside temperature is $in_temp degrees, windspeed is $wind miles an hour, pressure is $baro millibars and humidity is $hum percent";
my $req=new HTTP::Request GET => $url;
my $res = $ua->request($req);
print $url;