diff --git a/fhem/FHEM/99_SUNRISE_EL.pm b/fhem/FHEM/99_SUNRISE_EL.pm
index 1d0e3101e..45d93e411 100755
--- a/fhem/FHEM/99_SUNRISE_EL.pm
+++ b/fhem/FHEM/99_SUNRISE_EL.pm
@@ -87,15 +87,24 @@ sr_alt($$$$$$$$$)
my @lt = localtime($nt);
my $gmtoff = _calctz($nt,@lt); # in hour
- my ($rt,$st) = _sr_alt($altit,$needrise,$needset, $lt[5]+1900,$lt[4]+1,$lt[3], $gmtoff);
+ my ($rt,$st) = _sr_alt($altit,$needrise,$needset,
+ $lt[5]+1900,$lt[4]+1,$lt[3], $gmtoff);
my $sst = ($rise ? $rt : $st) + ($seconds/3600);
my $nh = $lt[2] + $lt[1]/60 + $lt[0]/3600; # Current hour since midnight
if($daycheck) {
- return 0 if($nh < $rt || $nh > $st);
- return 0 if(defined($min) && $nh < hms2h($min));
- return 0 if(defined($max) && $nh > hms2h($max));
- return 1;
+ if(defined($min) && defined($max)) { #Forum #43742
+ $min = hms2h($min); $max = hms2h($max);
+ if($min < $max) {
+ $rt = $min if($rt < $min);
+ $st = $max if($st > $max);
+ } else {
+ $rt = $max if($rt > $max);
+ $st = $min if($st < $min);
+ }
+ }
+ return 1 if($rt <= $nh && $nh <= $st);
+ return 0;
}
$sst = hms2h($min) if(defined($min) && (hms2h($min) > $sst));
@@ -109,7 +118,8 @@ sr_alt($$$$$$$$$)
my $ngmtoff = _calctz($nt,@lt); # in hour
$diff = 24+$gmtoff-$ngmtoff;
- ($rt,$st) = _sr_alt($altit,$needrise,$needset, $lt[5]+1900,$lt[4]+1,$lt[3], $ngmtoff);
+ ($rt,$st) = _sr_alt($altit,$needrise,$needset,
+ $lt[5]+1900,$lt[4]+1,$lt[3], $ngmtoff);
$sst = ($rise ? $rt : $st) + ($seconds/3600);
$sst = hms2h($min) if(defined($min) && (hms2h($min) > $sst));
@@ -400,17 +410,18 @@ sunrise, sunset,
sunrise_rel, sunset_rel
sunrise_abs, sunset_abs
isday
- perl functions, to be used in at or FS20 on-till commands.
+ perl functions, to be used in at or FS20 on-till commands.
+
First you should set the longitude and latitude global attributes to the
exact longitude and latitude values (see e.g. maps.google.com for the exact
values, which should be in the form of a floating point value). The default
value is Frankfurt am Main, Germany.
- The default altitude ($defaultaltit in SUNRISE_EL.pm) defines the sunrise/sunset
- for Civil twilight (i.e. one can no longer read outside without artificial
- illumination), which differs from sunrise/sunset times found on different
- websites. See perldoc "DateTime::Event::Sunrise" for alternatives.
-
+ The default altitude ($defaultaltit in SUNRISE_EL.pm) defines the
+ sunrise/sunset for Civil twilight (i.e. one can no longer read outside
+ without artificial illumination), which differs from sunrise/sunset times
+ found on different websites. See perldoc "DateTime::Event::Sunrise" for
+ alternatives.
sunrise()/sunset() returns the absolute time of the next sunrise/sunset,
adding 24 hours if the next event is tomorrow, to use it in the timespec of
@@ -420,9 +431,9 @@ isday
sunrise/sunset.
sunrise_abs()/sunset_abs() return the absolute time of the corresponding
event today (no 24 hours added).
- sunrise_abs_dat()/sunset_abs_dat() return the absolute time of the corresponding
- event to a given date(no 24 hours added).
-
+ sunrise_abs_dat()/sunset_abs_dat() return the absolute time of the
+ corresponding event to a given date(no 24 hours added).
+
All functions take up to three arguments:
# When sun is 6 degrees below horizon - same as sunrise();
sunrise("CIVIL");
- # When sun is 3 degrees below (-3 above) horizon (Between real and civil sunset)
+ # When sun is 3 degrees below horizon (between real and civil sunset)
sunset("HORIZON=-3");
# When sun is 1 degree above horizon
@@ -455,7 +471,9 @@ isday
- The functions sunrise_abs_dat()/sunset_abs_dat() need as a very first parameter the date(format epoch: time()) for which the events should be calculated.
+ The functions sunrise_abs_dat()/sunset_abs_dat() need as a very first
+ parameter the date(format epoch: time()) for which the events should be
+ calculated.