From f1b69feb7cb6398b6581ca97a2a93ff42e778839 Mon Sep 17 00:00:00 2001 From: unimatrix27 <> Date: Thu, 5 Apr 2012 10:02:56 +0000 Subject: [PATCH] replaced complex if-branch with simple array (contributed by Daniel Wiedemann) git-svn-id: https://svn.fhem.de/fhem/trunk@1414 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/59_Twilight.pm | 64 +++++----------------------------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/fhem/FHEM/59_Twilight.pm b/fhem/FHEM/59_Twilight.pm index 6570973e3..87a5f704b 100644 --- a/fhem/FHEM/59_Twilight.pm +++ b/fhem/FHEM/59_Twilight.pm @@ -263,68 +263,18 @@ sub twilight_calc { } 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("www.google.com:80", "/ig/api?weather=" . $location . "&hl=en"); - #$xml =~/\(.*)\<\/current_conditions\>/; - #my $current=$1; - #$current=~/\=0) && ($current <=47)) { + return $a_current[$current]; + } else { + return 1; + } } - 1;