| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856 |
- ##############################################
- # $Id: 99_SUNRISE_EL.pm 16266 2018-02-25 18:22:51Z rudolfkoenig $
- # This code is derived from DateTime::Event::Sunrise, version 0.0501.
- # Simplified and removed further package # dependency (DateTime,
- # Params::Validate, etc). For comments see the original code.
- #
- package main;
- use strict;
- use warnings;
- use Math::Trig;
- sub sr($$$$$$);
- sub sunrise_rel(@);
- sub sunset_rel(@);
- sub sunrise_abs(@);
- sub sunset_abs(@);
- sub isday(@);
- sub sunrise_coord($$$);
- sub SUNRISE_Initialize($);
- # See perldoc DateTime::Event::Sunrise for details
- my $long;
- my $lat;
- my $tz = ""; # will be overwritten
- 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 <number>
- sub
- SUNRISE_EL_Initialize($)
- {
- my ($hash) = @_;
- }
- ##########################
- # Compute the _next_ event
- # rise: 1: event is sunrise (else sunset)
- # isrel: 1: relative times
- # seconds: second offset to event
- # daycheck: if set, then return 1 if the sun is visible, 0 else
- sub
- sr($$$$$$)
- {
- my ($rise, $seconds, $isrel, $daycheck, $min, $max) = @_;
- sr_alt(time(), $rise, $isrel, $daycheck, 1, $defaultaltit,$seconds,$min,$max);
- }
- sub
- 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;
- } elsif($altit =~ /HORIZON=([\-\+]*[0-9\.]+)/i) {
- $altit=$1;
- shift;
- } else {
- $altit=-6; #default
- }
- my($seconds, $min, $max)=@_;
- my $needrise = ($rise || $daycheck) ? 1 : 0;
- my $needset = (!$rise || $daycheck) ? 1 : 0;
- $seconds = 0 if(!$seconds);
- ############################
- # 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");
- Log3 undef, 5, "Compute sunrise/sunset for latitude $lat , longitude $long";
-
- #my $nt = time;
- 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 $sst = ($rise ? $rt : $st) + ($seconds/3600);
- my $nh = $lt[2] + $lt[1]/60 + $lt[0]/3600; # Current hour since midnight
- if($daycheck) {
- 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));
- $sst = hms2h($max) if(defined($max) && (hms2h($max) < $sst));
- my $diff = 0;
- if (($data{AT_RECOMPUTE} || # compute it for tommorow
- int(($nh-$sst)*3600) >= 0) && $nextDay) { # if called a subsec earlier
- $nt += 86400;
- @lt = localtime($nt);
- my $ngmtoff = _calctz($nt,@lt); # in hour
- $diff = 24;
- ($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));
- $sst = hms2h($max) if(defined($max) && (hms2h($max) < $sst));
- }
- $sst += $diff if($isrel);
- $sst -= $nh if($isrel == 1);
- return h2hms_fmt($sst);
- }
- sub
- _sr_alt($$$$$$$)
- {
- my ($altit,$needrise, $needset, $y, $m, $dy, $offset) = @_;
- my $d = _days_since_2000_Jan_0($y,$m,$dy) + 0.5 - $long / 360.0;
- my ( $tmp_rise_1, $tmp_set_1 ) =
- _sunrise_sunset( $d, $long, $lat, $altit, 15.04107 );
- my ($tmp_rise_2, $tmp_rise_3) = (0,0);
- if($needrise) {
- $tmp_rise_2 = 9; $tmp_rise_3 = 0;
- until ( _equal( $tmp_rise_2, $tmp_rise_3, 8 ) ) {
- my $d_sunrise_1 = $d + $tmp_rise_1 / 24.0;
- ( $tmp_rise_2, undef ) =
- _sunrise_sunset( $d_sunrise_1, $long, $lat, $altit, 15.04107 );
- $tmp_rise_1 = $tmp_rise_3;
- my $d_sunrise_2 = $d + $tmp_rise_2 / 24.0;
- ( $tmp_rise_3, undef ) =
- _sunrise_sunset( $d_sunrise_2, $long, $lat, $altit, 15.04107 );
- }
- }
- my ($tmp_set_2, $tmp_set_3) = (0,0);
- if($needset) {
- $tmp_set_2 = 9; $tmp_set_3 = 0;
- until ( _equal( $tmp_set_2, $tmp_set_3, 8 ) ) {
- my $d_sunset_1 = $d + $tmp_set_1 / 24.0;
- ( undef, $tmp_set_2 ) =
- _sunrise_sunset( $d_sunset_1, $long, $lat, $altit, 15.04107 );
- $tmp_set_1 = $tmp_set_3;
- my $d_sunset_2 = $d + $tmp_set_2 / 24.0;
- ( undef, $tmp_set_3 ) =
- _sunrise_sunset( $d_sunset_2, $long, $lat, $altit, 15.04107 );
- }
- }
- return $tmp_rise_3+$offset, $tmp_set_3+$offset;
- }
- sub
- _sunrise_sunset($$$$$)
- {
- my ( $d, $lon, $lat, $altit, $h ) = @_;
- my $sidtime = _revolution( _GMST0($d) + 180.0 + $lon );
- # Compute Sun's RA + Decl + distance at this moment
- my ( $sRA, $sdec, $sr ) = _sun_RA_dec($d);
- # Compute time when Sun is at south - in hours UT
- my $tsouth = 12.0 - _rev180( $sidtime - $sRA ) / $h;
- # Compute the diurnal arc that the Sun traverses to reach
- # the specified altitude altit:
- my $cost =
- ( sind($altit) - sind($lat) * sind($sdec) ) /
- ( cosd($lat) * cosd($sdec) );
- my $t;
- if ( $cost >= 1.0 ) {
- $t = 0.0; # Sun always below altit
- }
- elsif ( $cost <= -1.0 ) {
- $t = 12.0; # Sun always above altit
- }
- else {
- $t = acosd($cost) / 15.0; # The diurnal arc, hours
- }
- # Store rise and set times - in hours UT
- my $hour_rise_ut = $tsouth - $t;
- my $hour_set_ut = $tsouth + $t;
- return ( $hour_rise_ut, $hour_set_ut );
- }
- sub
- _GMST0($)
- {
- my ($d) = @_;
- my $sidtim0 =
- _revolution( ( 180.0 + 356.0470 + 282.9404 ) +
- ( 0.9856002585 + 4.70935E-5 ) * $d );
- return $sidtim0;
- }
- sub
- _sunpos($)
- {
- my ($d) = @_;
- my $Mean_anomaly_of_sun = _revolution( 356.0470 + 0.9856002585 * $d );
- my $Mean_longitude_of_perihelion = 282.9404 + 4.70935E-5 * $d;
- my $Eccentricity_of_Earth_orbit = 0.016709 - 1.151E-9 * $d;
- # Compute true longitude and radius vector
- my $Eccentric_anomaly =
- $Mean_anomaly_of_sun + $Eccentricity_of_Earth_orbit * $RADEG *
- sind($Mean_anomaly_of_sun) *
- ( 1.0 + $Eccentricity_of_Earth_orbit * cosd($Mean_anomaly_of_sun) );
- my $x = cosd($Eccentric_anomaly) - $Eccentricity_of_Earth_orbit;
- my $y =
- sqrt( 1.0 - $Eccentricity_of_Earth_orbit * $Eccentricity_of_Earth_orbit )
- * sind($Eccentric_anomaly);
- my $Solar_distance = sqrt( $x * $x + $y * $y ); # Solar distance
- my $True_anomaly = atan2d( $y, $x ); # True anomaly
- my $True_solar_longitude =
- $True_anomaly + $Mean_longitude_of_perihelion; # True solar longitude
- if ( $True_solar_longitude >= 360.0 ) {
- $True_solar_longitude -= 360.0; # Make it 0..360 degrees
- }
- return ( $Solar_distance, $True_solar_longitude );
- }
- # Sun's Right Ascension (RA), Declination (dec) and distance (r)
- sub
- _sun_RA_dec($)
- {
- my ($d) = @_;
- my ( $r, $lon ) = _sunpos($d);
- my $x = $r * cosd($lon);
- my $y = $r * sind($lon);
- my $obl_ecl = 23.4393 - 3.563E-7 * $d;
- my $z = $y * sind($obl_ecl);
- $y = $y * cosd($obl_ecl);
- my $RA = atan2d( $y, $x );
- my $dec = atan2d( $z, sqrt( $x * $x + $y * $y ) );
- return ( $RA, $dec, $r );
- }
- sub
- _days_since_2000_Jan_0($$$)
- {
- my ($y, $m, $d) = @_;
- my @mn = (31,28,31,30,31,30,31,31,30,31,30,31);
-
- my $ms = 0;
- for(my $i = 0; $i < $m-1; $i++) {
- $ms += $mn[$i];
- }
- my $x = ($y-2000)*365.25 + $ms + $d;
- $x++ if($m > 2 && ($y%4) == 0);
- return int($x);
- }
- sub sind($) { sin( ( $_[0] ) * $DEGRAD ); }
- sub cosd($) { cos( ( $_[0] ) * $DEGRAD ); }
- sub tand($) { tan( ( $_[0] ) * $DEGRAD ); }
- sub atand($) { ( $RADEG * atan( $_[0] ) ); }
- sub asind($) { ( $RADEG * asin( $_[0] ) ); }
- sub acosd($) { ( $RADEG * acos( $_[0] ) ); }
- sub atan2d($$) { ( $RADEG * atan2( $_[0], $_[1] ) ); }
- sub
- _revolution($)
- {
- my $x = $_[0];
- return ( $x - 360.0 * int( $x * $INV360 ) );
- }
- sub
- _rev180($)
- {
- my ($x) = @_;
- return ( $x - 360.0 * int( $x * $INV360 + 0.5 ) );
- }
- sub
- _equal($$$)
- {
- my ( $A, $B, $dp ) = @_;
- return sprintf( "%.${dp}g", $A ) eq sprintf( "%.${dp}g", $B );
- }
- sub
- _calctz($@)
- {
- my ($nt,@lt) = @_;
- my $off = $lt[2]*3600+$lt[1]*60+$lt[0];
- $off = 12*3600-$off;
- $nt += $off; # This is noon, localtime
- my @gt = gmtime($nt);
- return (12-$gt[2]);
- }
-
- sub
- hms2h($)
- {
- my $in = shift;
- my @a = split(":", $in);
- return 0 if(int(@a) < 2 || $in !~ m/^[\d:]*$/);
- return $a[0]+$a[1]/60 + ($a[2] ? $a[2]/3600 : 0);
- }
- sub
- h2hms($)
- {
- my ($in) = @_;
- my ($h,$m,$s);
- $h = int($in);
- $m = int(60*($in-$h));
- $s = int(3600*($in-$h)-60*$m);
- return ($h, $m, $s);
- }
- sub
- h2hms_fmt($)
- {
- my ($in) = @_;
- my ($h,$m,$s) = h2hms($in);
- return sprintf("%02d:%02d:%02d", $h, $m, $s);
- }
- sub
- sr_noon($)
- {
- my ($date) = @_;
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($date);
- return $date - $hour*3600 - $min*60 - $sec + 12*3600;
- }
- sub sunrise_coord($$$) { ($long, $lat, $tz) = @_; return undef; }
- sub sunrise_rel(@) { return sr_alt(time(),1,1,0,1,shift,shift,shift,shift); }
- sub sunset_rel (@) { return sr_alt(time(),0,1,0,1,shift,shift,shift,shift); }
- sub sunrise_abs(@) { return sr_alt(time(),1,0,0,0,shift,shift,shift,shift); }
- sub sunset_abs (@) { return sr_alt(time(),0,0,0,0,shift,shift,shift,shift); }
- sub sunrise (@) { return sr_alt(time(),1,2,0,1,shift,shift,shift,shift); }
- sub sunset (@) { return sr_alt(time(),0,2,0,1,shift,shift,shift,shift); }
- sub isday (@) { return sr_alt(time(),1,0,1,1,shift,shift,shift,shift); }
- sub sunrise_abs_dat(@) {
- return sr_alt(sr_noon(shift),1,0,0,0,shift,shift,shift,shift);
- }
- sub sunset_abs_dat (@) {
- return sr_alt(sr_noon(shift),0,0,0,0,shift,shift,shift,shift);
- }
- 1;
- =pod
- =item helper
- =item summary perl functions to compute the sun position
- =item summary_DE perl Funktionen für die Sonnenstandsberechnung
- =begin html
- <a name="SUNRISE_EL"></a>
- <h3>SUNRISE_EL</h3>
- <ul>
- This module is used to define the functions<pre>
- sunrise, sunset,
- sunrise_rel, sunset_rel
- sunrise_abs, sunset_abs
- isday</pre>
- perl functions, to be used in <a href="#at">at</a> or FS20 on-till commands.
- <br>
- 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.
- <br><br>
- 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. <br><br>
- 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
- an at device or for the on-till command for FS20 devices.<br>
- sunrise_rel()/sunset_rel() returns the relative time to the next
- sunrise/sunset. <br>
- sunrise_abs()/sunset_abs() return the absolute time of the corresponding
- event today (no 24 hours added).<br>
- sunrise_abs_dat()/sunset_abs_dat() return the absolute time of the
- corresponding event to a given date(no 24 hours added).<br>
- All functions take up to three arguments:<br>
- <ul>
- <li>The first specifies an offset (in seconds), which will be added to the
- event.</li>
- <li>The second and third specify min and max values (format: "HH:MM").</li>
- </ul>
- <br>
- isday() can be used in some notify or at commands to check if the sun is up
- or down. isday() ignores the seconds parameter, but respects min and max.
- If min < max, than the day starts not before min, and ends not after max.
- If min > max, than the day starts not after max, and ends not before min.
- <br><br>
- Optionally, for all functions you can set first argument which defines a
- horizon value which then is used instead of the $defaultaltit in
- SUNRISE_EL.pm.<br> Possible values are: "REAL", "CIVIL", "NAUTIC",
- "ASTRONOMIC" or a positive or negative number preceded by "HORIZON="<br> REAL
- is 0, CIVIL is -6, NAUTIC is -12, ASTRONOMIC is -18 degrees above
- horizon.<br><br>
- Examples:<br>
- <ul>
- <PRE>
- # When sun is 6 degrees below horizon - same as sunrise();
- sunrise("CIVIL");
- # When sun is 3 degrees below horizon (between real and civil sunset)
- sunset("HORIZON=-3");
- # When sun is 1 degree above horizon
- sunset("HORIZON=1");
- # Switch lamp1 on at real sunset, not before 18:00 and not after 21:00
- define a15 at *{sunset("REAL",0,"18:00","21:00")} set lamp1 on
- </PRE>
- </ul>
-
- 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.
- <br><br>
- Examples:
- <br>
- <ul>
- <PRE>
- # to calculate the sunrise of today + 7 days
- my $date = time() + 7*86400;
- sunrise_abs_dat($date);
-
- # to calculate the sunrise of today + 7 days 6 degrees below horizon
- my $date = time() + 7*86400;
- sunrise_abs_dat($date, "CIVIL");
- </ul>
- </PRE>
-
- <b>Define</b> <ul>N/A</ul><br>
- <b>Set</b> <ul>N/A</ul><br>
- <b>Get</b> <ul>N/A</ul><br>
- <b>Attributes</b><br>
- <ul>
- <a name="latitude"></a>
- <li>latitude<br>
- If set, this latitude is used to calculate sunset/sunrise<br>
- Notation need to be in decimal format (for example Berlin = 52.666)
- As default Frankfurt/Main, Germany (50.112) is used.
- </li><br>
- <a name="longitude"></a>
- <li>longitude<br>
- If set, this longitude is used to calculate sunset/sunrise<br>
- Notation need to be in decimal format (for example Berlin = 13.400)
- As default Frankfurt/Main, Germany (8.686) is used.
- </li><br>
- <a name="altitude"></a>
- <li>altitude<br>
- Used by other modules.
- </li><br>
- Note: these are global attributes, e.g.<br>
- <ul>
- attr global latitude 50.112<br>
- attr global longitude 8.686<br>
- </ul>
- </ul><br>
- </ul>
- =end html
- =begin html_DE
- <a name="SUNRISE_EL"></a>
- <h3>SUNRISE_EL</h3>
- <ul>
- <p>
- <strong>SUNRISE_EL</strong> definiert eine Reihe von Perl-Subroutinen (<abbr>z.B.</abbr> zur Nutzung mit <a href="#at">at</a>):
- </p>
- <ul>
- <li><code>sunrise()</code> - absolute Zeit des nächsten Sonnenaufgangs (+ 24 h, wenn am nächsten Tag)</li>
- <li><code>sunset()</code> - absolute Zeit des nächsten Sonnenuntergangs (+ 24 h, wenn am nächsten Tag)</li>
- <li><code>sunrise_rel()</code> - relative Zeit des nächsten Sonnenaufgangs</li>
- <li><code>sunset_rel()</code> - relative Zeit des nächsten Sonnenuntergangs</li>
- <li><code>sunrise_abs()</code> - absolute Zeit des nächsten Sonnenaufgangs (ohne Stundenzuschlag)</li>
- <li><code>sunset_abs()</code> - relative Zeit des nächsten Sonnenuntergangs (ohne Stundenzuschlag)</li>
- <li><code>sunrise_abs_dat()</code> - absolute Zeit des nächsten Sonnenaufgangs an einem bestimmten Tag</li>
- <li><code>sunset_abs_dat()</code> - relative Zeit des nächsten Sonnenuntergangs an einem bestimmten Tag</li>
- <li><code>isday()</code> - Tag oder Nacht</li>
- </ul>
- <h4>Breite, Länge und Höhenwinkel</h4>
- <p>
- Bevor du <strong>SUNRISE_EL</strong> verwendest, solltest du im <a href="#global">global-Device</a> die
- Werte für <span>latitude</span> (geographische Breite) und <span>longitude</span> (geographische Länge) entsprechend
- deines Standorts setzen.
- </p>
- <div>
- <h4>Exkurs: <span>latitude</span> & <span>longitude</span> ermitteln</h4>
- <p>
- Deine geopgragischen Koordinaten kannst du <abbr>z.B.</abbr> mit <a href="https://maps.google.com">Google Maps</a> bestimmen.
- Dazu setzt du einen Punkt auf der Karte und findest dann im unteren Bereich der Karte die Angabe für beide Werte.
- Der erste Wert ist die geographische Breite (<span>latitude</span>); der zweite Wert die geographische Länge
- (<span>longitude</span>).
- </p>
- <p>
- Der <span>Default</span>-Wert ist 50.112, 8.686 (<a href="https://goo.gl/maps/vkyedDL1DJp">Frankfurt am Main</a>).
- </p>
- </div>
- <p>
- <strong>SUNRISE_EL</strong> geht von einem Höhenwinkel der Sonne bezogen zum Horizont, <var>h</var>, von -6° aus. Dieser Wert bedeutet,
- dass die Sonne 6° <strong>unter</strong> dem Horizont steht und Lesen im Freien ohne künstliche Beleuchtung nicht
- mehr möglich ist (<span>civil twilight</span>, bürgerliche Dämmerung).
- <strong>SUNRISE_EL</strong> speichert diesen Wert in <var><code>$defaultaltit</code></var>.
- </p>
- <p>
- Siehe auch <a href="http://search.cpan.org/~jforget/DateTime-Event-Sunrise-0.0505/lib/DateTime/Event/Sunrise.pm">perldoc DateTime::Event::Sunrise</a> für
- weitere Hinweise.
- </p>
- <h4>Befehlsreferenz</h4>
- <h5>Parameter</h5>
- <p>
- Jede der folgenden Funktionen akzeptiert bis zu vier (<abbr>bzw.</abbr> fünf) Parameter in der angegebenen Reihenfolge:
- </p>
- <dl>
- <dt>
- <var>unix timestamp</var>
- </dt>
- <dd>
- <p>
- <strong>Ausschließlich</strong> <code>sunrise_abs_dat()</code> & <code>sunset_abs_dat()</code>
- erwarten als ersten Parameter einen Unix-Timestamp (Unix-Epoche) in Sekunden, der ein Datum spezifiziert. Andere Subroutinen
- erwarten diesen Parameter nicht!
- </p>
- </dd>
- <dt>
- <var>altitude</var>
- </dt>
- <dd>
- <p>
- Eine der folgenden Zeichenketten, die unterschiedliche Höhenwinkel <var>h</var> definieren und den Wert
- von <code><var>$defaultaltit</var></code> verändern.
- </p>
- <p>
- Erlaubte Werte sind:
- </p>
- <ul>
- <li>
- <code><var>REAL</var></code>, <var>h</var> = 0°,
- </li>
- <li>
- <code><var>CIVIL</var></code>, <var>h</var> = -6°,
- </li>
- <li>
- <code><var>NAUTIC</var></code>, <var>h</var> = -12°,
- </li>
- <li>
- <code><var>ASTRONOMIC</var></code>, <var>h</var> = -18°,
- </li>
- <li>
- oder <code><var>HORIZON=</var></code>, gefolgt von einer positiven oder negativen Zahl ohn Gradzeichen, die einen Höhenwinkel
- angibt.
- </li>
- </ul>
- </dd>
- <dt>
- <var>offset</var>
- </dt>
- <dd>
- <p>
- <span>Offset</span> in Sekunden, der zu dem Rückgabewert der Funktion addiert wird.
- </p>
- <p>
- <code>isday()</code>
- ignoriert diesen Wert.
- </p>
- </dd>
- <dt>
- <var>min</var>
- </dt>
- <dd>
- <p>
- Einen Zeitstempel im Format <var>hh:mm</var>, vor dem keine Aktion ausgeführt werden soll.
- </p>
- <p>
- <code>isday()</code> wird <var>(int) 0</var> zurückliefern, wenn <var>min</var> gesetzt
- und der aktuelle Zeitstempel kleiner ist.
- </p>
- </dd>
- <dt>
- <var>max</var>
- </dt>
- <dd>
- <p>
- Einen Zeitstempel im Format <var>hh:mm</var>, nach dem keine Aktion ausgeführt werden soll.
- </p>
- <p>
- <code>isday()</code> wird <var>(int) 0</var> zurückliefern, wenn <var>max</var> gesetzt
- und der aktuelle Zeitstempel größer ist.
- </p>
- </dd>
- </dl>
- <h5>Subroutinen</h5>
- <dl>
- <dt>
- <p><code>sunrise(), sunset()</code></p>
- </dt>
- <dd>
- liefern den absoluten Wert des nächsten Sonnenauf- <abbr>bzw.</abbr> -untergangs zurück, wobei 24 Stunden zu
- diesem Wert addiert werden,
- wenn der Zeitpunkt am nächsten Tag sein wird, im Format <var>hh:mm:ss</var>.
- </dd>
- <dt>
- <p><code>sunrise_rel(), sunset_rel()</code></p>
- </dt>
- <dd>
- liefern die relative Zeit bis zum nächsten Sonnenauf- <abbr>bzw.</abbr> -untergang im Format
- <var>hh:mm:ss</var>.
- </dd>
- <dt>
- <p><code>sunrise_abs(), sunset_abs()</code></p>
- </dt>
- <dd>
- liefern den nächsten absoluten Zeitpunkt des nächsten Sonnenauf- <abbr>bzw.</abbr> -untergangs
- <strong>ohne</strong> 24 Stunden
- zu addieren im Format <var>hh:mm:ss</var>.
- </dd>
- <dt>
- <p><code>sunrise_abs_dat(), sunset_abs()_dat</code></p>
- </dt>
- <dd>
- liefern den nächsten absoluten Zeitpunkt des nächsten Sonnenauf- <abbr>bzw.</abbr> -untergangs
- <strong>ohne</strong> 24 Stunden zu addieren im Format <var>hh:mm:ss</var> zu einem als ersten Parameter angegebenen Datum.
- </dd>
- <dt>
- <p><code>isday()</code></p>
- </dt>
- <dd>
- liefert <var>(int) 1</var> wenn Tag ist, <var>(int) 0</var> wenn Nacht ist.
- </dd>
- </dl>
- <h5>Beispiele</h5>
- <dl>
- <dt>
- <p>
- <code>sunrise("CIVIL");</code>
- </p>
- </dt>
- <dd>
- <p>
- Zeitpunkt des Sonnenaufgangs bei einem Höhenwinkel der Sonne von -6° unter dem Horizont (identisch zu <code>sunrise()</code>).
- </p>
- </dd>
- <dt>
- <p>
- <code>sunset("HORIZON=-3");</code>
- </p>
- </dt>
- <dd>
- <p>
- Zeitpunkt des Sonnenuntergangs bei einem Höhenwinkel der Sonne von 3° unter dem Horizont
- (zwischen <code><var>REAL</var></code> und <code><var>CIVIL</var></code>).
- </p>
- </dd>
- <dt>
- <p>
- <code>sunset("HORIZON=1");</code>
- </p>
- </dt>
- <dd>
- <p>
- Zeitpunkt des Sonnenaufgangs bei einem Höhenwinkel der Sonne von 1° über dem Horizont.
- </p>
- </dd>
- <dt>
- <p>
- <code>defmod a15 at *{sunset("REAL",0,"18:00","21:00")} set lamp1 on</code>
- </p>
- </dt>
- <dd>
- <p>
- Schalte <var>lamp1</var> an, sobald die Sonne unter den Horizont sinkt (<var>h ≤ 0</var>), jedoch nicht vor 18:00 und nicht nach 21:00.
- </p>
- </dd>
- <dt>
- <p>
- <code>
- my $date = time() + 7*86400;<br />
- sunrise_abs_dat($date);
- </code>
- </p>
- </dt>
- <dd>
- <p>
- Berechne den Sonnenaufgang von heute + sieben Tage.
- </p>
- </dd>
- <dt>
- <p>
- <code>
- my $date = time() + 7*86400;<br />
- sunrise_abs_dat($date, "CIVIL");
- </code>
- </p>
- </dt>
- <dd>
- <p>
- Berechne den Sonnenaufgang von heute + sieben Tage mit einem Höhenwinkel <var>h = -6°</var>.
- </p>
- </dd>
- </dl>
- <h4>Define</h4>
- <blockquote>
- <strong>SUNRISE_EL</strong> kann nicht explizit als <span>Device</span> definiert werden,
- sondern bietet die oben genannten Subroutinen.
- </blockquote>
- <h4>Set</h4>
- <blockquote>
- <strong>SUNRISE_EL</strong> unterstützt <var>set</var> nicht.
- </blockquote>
- <h4>Get</h4>
- <blockquote>
- <strong>SUNRISE_EL</strong> unterstützt <var>get</var> nicht.
- </blockquote>
- <h4>Attribute</h4>
- <p>
- Diese Attribute müssen im <span><a href="#global">global</a>-Device</span> gesetzt werden!
- </p>
- <dl>
- <dt>
- <p>
- <var>latitude</var>
- </p>
- </dt>
- <dd>
- <blockquote>
- Geographische Breite in Dezimalgrad in Form eines <code>float</code>, <abbr>z.B</abbr> <code><var>49.872471</var></code>.
- </blockquote>
- <blockquote>
- <span>Default</span>-Wert ist <code><var>50.112</var></code>.
- </blockquote>
- </dd>
- <dt>
- <p>
- <var>longitude</var>
- </p>
- </dt>
- <dd>
- <blockquote>
- Geographische Länge in Dezimalgrad in Form eines <code>float</code>, <abbr>z.B</abbr> <code><var>8.650991</var></code>.
- </blockquote>
- <blockquote>
- <span>Default</span>-Wert ist <code><var>8.686</var></code>.
- </blockquote>
- </dd>
- <dt>
- <p>
- <var>altitude</var>
- </p>
- </dt>
- <dd>
- <blockquote>
- Höhenwinkel <var>h</var> der Sonne bezogen auf den Horizont in Grad in Form einer Zahl ohne Gradzeichen.
- </blockquote>
- <blockquote>
- <span>Default</span>-Wert ist <code><var>-6</var></code>.
- </blockquote>
- </dd>
- </dl>
- </ul>
- =end html_DE
- =cut
|