GetHttpFile now uses new Timeout Parameter

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@1432 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
unimatrix27
2012-04-10 07:08:19 +00:00
parent e016d5110e
commit a171ec99ad

View File

@@ -7,7 +7,6 @@
package main;
use strict;
use warnings;
use Switch;
use POSIX;
sub dayofyear {
@@ -266,13 +265,17 @@ sub Twilight_getWeatherHorizon{
my @a_current = (25,25,25,25,20,10,10,10,10,10,10,7,7,7,5,10,10,6,6,6,10,6,6,6,6,6,6,5,5,3,3,0,0,0,0,7,0,15,15,15,9,15,8,5,12,6,8,8);
#condition codes are described in FHEM wiki and in the documentation of the yahoo weather API
my $location=shift;
my $xml = GetHttpFile("weather.yahooapis.com:80","/forecastrss?w=".$location."&u=c");
$xml=~/code="(.*)"(\ *)temp/;
my $current=$1;
if(($current>=0) && ($current <=47)) {
return $a_current[$current];
} else {
return 1;
my $xml = GetHttpFile("weather.yahooapis.com:80","/forecastrss?w=".$location."&u=c",4.0);
my $current;
if($xml=~/code="(.*)"(\ *)temp/){
$current=$1;
if(($current>=0) && ($current <=47)) {
return $a_current[$current];
} else {
return 0;
}
}else{
return 0;
}
}