From 8c5d1f22cc67ecff142a5a341027715d35a2d8da Mon Sep 17 00:00:00 2001 From: dietmar63 Date: Fri, 25 Jul 2014 22:13:51 +0000 Subject: [PATCH] Twilight - by omitting the yahooID the weaterinformation will not be read git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6318 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/59_Twilight.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/59_Twilight.pm b/fhem/FHEM/59_Twilight.pm index 7f985604b..2282cdfe3 100644 --- a/fhem/FHEM/59_Twilight.pm +++ b/fhem/FHEM/59_Twilight.pm @@ -130,8 +130,8 @@ sub Twilight_Define($$) return "Argument Longitude is not a valid number"; } - my $weather = ""; - my $indoor_horizon="4"; + my $weather = 0; + my $indoor_horizon ="4"; if(int(@a)>5) { $weather=$a[5] } if(int(@a)>4) { if ($a[4] =~ /^[\+-]*[0-9]*\.*[0-9]*$/ && $a[4] !~ /^[\. ]*$/ ) { $indoor_horizon = $a[4]; @@ -388,7 +388,7 @@ sub Twilight_calc($$$$$$$) { my ($latitude, $longitude, $horizon, $declination, $timezone, $midseconds, $timediff) = @_; - my $bogRad = 360/2/pi; # ~ 57.29578° + my $bogRad = 360/2/pi; # ~ 57.29578° # $s1--| $s2-------------------| $s3---------------------| # Zeitdifferenz = 12*arccos((sin(h) - sin(B)*sin(Deklination)) / (cos(B)*cos(Deklination)))/Pi; my $s1 = sin($horizon /$bogRad); @@ -412,6 +412,13 @@ sub Twilight_calc($$$$$$$) sub Twilight_getWeatherHorizon($) { my $hash=shift; # 0 + + my $location=$hash->{WEATHER}; + if ($location == 0) { + $hash->{WEATHER_HORIZON}="0"; + $hash->{CONDITION}="0"; + return 1; + } my $mod = "[".$hash->{NAME} ."] "; my @a_current = (25,25,25,25,20,10,10,10,10,10, @@ -421,7 +428,6 @@ sub Twilight_getWeatherHorizon($) 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=$hash->{WEATHER}; my $url = "http://weather.yahooapis.com/forecastrss?w=".$location."&u=c"; my $xml = GetFileFromURL($url, 3, undef, 1); @@ -451,8 +457,8 @@ sub Twilight_getWeatherHorizon($) .$xml ."\n======="; - $hash->{WEATHER_HORIZON}="0"; - $hash->{CONDITION}="-1"; + $hash->{WEATHER_HORIZON} = "0"; + $hash->{CONDITION} = "-1"; } ################################################################################ sub Twilight_sunpos($)