diff --git a/fhem/FHEM/99_SUNRISE_EL.pm b/fhem/FHEM/99_SUNRISE_EL.pm index 077f5afaf..ae26aca52 100644 --- a/fhem/FHEM/99_SUNRISE_EL.pm +++ b/fhem/FHEM/99_SUNRISE_EL.pm @@ -28,7 +28,7 @@ my $defaultaltit = "-6"; # Civil twilight my $RADEG = ( 180 / 3.1415926 ); my $DEGRAD = ( 3.1415926 / 180 ); my $INV360 = ( 1.0 / 360.0 ); -my %alti = (REAL => 0, CIVIL => -6, NAUTIC => -12, ASTRONOMIC => -16); # or HORIZON +my %alti = (REAL=>0, CIVIL=>-6, NAUTIC=>-12, ASTRONOMIC=>-16); # or HORIZON= sub @@ -61,24 +61,29 @@ sr($$$$$$) } sub -sr_alt($$$$$$$$$) +sr_alt($$$$$$$$$;$$) { - my $nt=shift; - my $rise=shift; - my $isrel=shift; - my $daycheck=shift; - my $nextDay=shift; - my $altit = defined($_[0]) ? $_[0] : ""; - if(exists $alti{uc($altit)}) { - $altit=$alti{uc($altit)}; - shift; + my $nt = shift; + my $rise = shift; + my $isrel = shift; + my $daycheck= shift; + my $nextDay = shift; + my $altit = shift; + my $seconds = shift; + my $min = shift; + my $max = shift; + $lat = shift; + $long = shift; + + $altit = defined($altit) ? uc($altit) : ""; + if(exists $alti{$altit}) { + $altit = $alti{$altit}; } elsif($altit =~ /HORIZON=([\-\+]*[0-9\.]+)/i) { - $altit=$1; - shift; + $altit=$1; } else { - $altit=-6; #default + $altit=-6; #default } - my($seconds, $min, $max)=@_; + my $needrise = ($rise || $daycheck) ? 1 : 0; my $needset = (!$rise || $daycheck) ? 1 : 0; $seconds = 0 if(!$seconds); @@ -87,8 +92,8 @@ sr_alt($$$$$$$$$) # If set in global, use longitude/latitude # from global, otherwise set Frankfurt/Germany as # default - $long = AttrVal("global", "longitude", "8.686"); - $lat = AttrVal("global", "latitude", "50.112"); + $long = AttrVal("global", "longitude", "8.686") if(!defined($long)); + $lat = AttrVal("global", "latitude", "50.112") if(!defined($lat)); Log3 undef, 5, "Compute sunrise/sunset for latitude $lat , longitude $long";