Hey CubsFan,

I hacked an older version of SDT to work with my home weather station.
I'm trying to re-hack the latest version to work with it, and am trying
to get your WeatherUnderground function to do the trick. (The current
version of my station software doesn't work with WeatherUnderground.)
Unfortunately I'm definitely doing something wrong.

Here's the output of my weather station:

ti:12:14 PM
ot:71.5
hi:72.5
lo:47.3
hu:47
ws:1
wd:292
wc:71.5
pr:29.895
dr:0.0
rr:0.0
so:945
uv:9.2

I've tried to adapt this to WUnderground but it's obvious I'm doing
something wrong. Here's my code:


sub getWunderground {  #Set up Async HTTP request for Weather
        my $url = '[my URL]';
        my $http = Slim::Networking::SimpleAsyncHTTP->new(\&gotWunderground,
                                                  \&gotErrorViaHTTP,
                                                  {caller => 
'getWunderground'});
        $::d_plugins && msg("SuperDateTime: async request: $url\n");
        $http->get($url);

}

sub gotWunderground {  #Weather data was received
        my $http = shift;
        
        my $temperatureF;
        my $temperatureC;
        my $dewpointF;
        my $dewpointC;
        my $humidity;
        my $pressureIN;
        my $pressureMB;
        my $pressureT; #Pressure trend
        my $windspeed;
        my $winddir; #Wind from direction

        $::d_plugins && msg("SuperDateTime: got " . $http->url() . "\n");

        my $content = $http->content();
        my @ary=split /\n/,$content; #break large string into array

        #$::d_plugins && msg("WU DATA: ".$ary[scalar(@ary)-3]."\n");

                if (/ot:([0-9.]+)/) {
                $temperatureF = $1;
                $temperatureC = FtoC($temperatureF); 
}
                elsif (/hu:(\d+)/) {
                        $humidity = $1;
                }
                elsif (/dr:(\d+\.\d+)/) {
                        $windspeed = $1;
                }

                
                elsif (/pr:(\d+\.\d+)/) {
                        $pressureIN = $1;
                $pressureMB = $3 * 33.8639;
                $pressureMB = int($pressureMB + .5 * ($pressureMB <=> 0)); 
#Funky
round   
                }
                
                }

Any thoughts about what I'm doing wrong? Would I be better off
programming my server output to fake a weather underground output?


-- 
jsnell
------------------------------------------------------------------------
jsnell's Profile: http://forums.slimdevices.com/member.php?userid=66
View this thread: http://forums.slimdevices.com/showthread.php?t=14327

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/plugins

Reply via email to