2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

added check if weather location is valid. if not, generate log entry and give meaningful values to readings

git-svn-id: https://svn.fhem.de/fhem/trunk@1481 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
unimatrix27 2012-04-24 10:20:49 +00:00
parent 03095993ef
commit 974306afd7

View File

@ -270,18 +270,20 @@ sub Twilight_getWeatherHorizon{
my $xml = GetHttpFile("weather.yahooapis.com:80","/forecastrss?w=".$location."&u=c",4.0);
my $current;
if($xml=~/code="(.*)"(\ *)temp/){
if(defined($1)){
$current=$1;
}else{
$current=-1;
}
if(($current>=0) && ($current <=47)) {
$hash->{WEATHER_HORIZON}=$a_current[$current]+$hash->{INDOOR_HORIZON};
$hash->{CONDITION}=$current;
return 1;
} else {
return 0;
}
}else{
return 0;
}
}
Log 1, "[TWILIGHT] No Weather location found at yahoo weather for location ID: $location";
$hash->{WEATHER_HORIZON}="0";
$hash->{CONDITION}="-1";
}
1;