From 974306afd786cddac8cf5b30d3f07cdcdce3c63f Mon Sep 17 00:00:00 2001 From: unimatrix27 <> Date: Tue, 24 Apr 2012 10:20:49 +0000 Subject: [PATCH] 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 --- fhem/FHEM/59_Twilight.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fhem/FHEM/59_Twilight.pm b/fhem/FHEM/59_Twilight.pm index a45504d90..e83301299 100644 --- a/fhem/FHEM/59_Twilight.pm +++ b/fhem/FHEM/59_Twilight.pm @@ -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/){ - $current=$1; + 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;