2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 10:46:53 +00:00

99_SUNRISE_EL.pm: add lat/long as optional parameter to sr_alt (Forum )

git-svn-id: https://svn.fhem.de/fhem/trunk@22774 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-09-15 16:17:56 +00:00
parent 14244b3d52
commit 7c65595bd3

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