2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 04:36:36 +00:00

- Twilight, improvement without efects in calculation

- WOL, immediate refresh after set command

git-svn-id: https://svn.fhem.de/fhem/trunk@4568 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
dietmar63 2014-01-05 23:10:13 +00:00
parent 0dc5f9246f
commit 02fcf125d2
2 changed files with 17 additions and 6 deletions

View File

@ -5,6 +5,8 @@
# Copyright by Sebastian Stuecker
# erweitert von Dietmar Ortmann
#
# used algorithm see: http://lexikon.astronomie.info/zeitgleichung/
#
# Sun position computing
# Copyright (C) 2013 Julian Pawlowski, julian.pawlowski AT gmail DOT com
# based on Twilight.tcl http://www.homematic-wiki.info/mw/index.php/TCLScript:twilight
@ -183,7 +185,10 @@ sub Twilight_TwilightTimes($$)
my $midseconds = $now-$midnight;
my $doy = strftime("%j",localtime);
#
# WOZ - MOZ = -0.171*sin(0.0337 * T + 0.465) - 0.1299*sin(0.01787 * T - 0.168)
# Deklination = 0.4095*sin(0.016906*(T-80.086))
#
my $timezone = Twilight_my_gmt_offset();
my $timediff = -0.171 *sin(0.0337 * $doy+0.465) - 0.1299*sin(0.01787 * $doy - 0.168);
my $declination= 0.4095*sin(0.016906*($doy-80.086));
@ -371,13 +376,17 @@ sub Twilight_calc($$$$$$$)
{
my ($latitude, $longitude, $horizon, $declination, $timezone, $midseconds, $timediff) = @_;
my $s1 = sin($horizon /57.29578);
my $s2 = sin($latitude/57.29578) * sin($declination);
my $s3 = cos($latitude/57.29578) * cos($declination);
my $bogRad = 360/2/pi; # ~ 57.29578°
# $s1--| $s2-------------------| $s3---------------------|
# Zeitdifferenz = 12*arccos((sin(h) - sin(B)*sin(Deklination)) / (cos(B)*cos(Deklination)))/Pi;
my $s1 = sin($horizon /$bogRad);
my $s2 = sin($latitude/$bogRad) * sin($declination);
my $s3 = cos($latitude/$bogRad) * cos($declination);
my ($suntime, $sunrise, $sunset);
my $acosArg = ($s1 - $s2) / $s3;
if (abs($acosArg) < 1.0) { # ok
if (abs($acosArg) < 1.0) { # ok
$suntime = 12*acos($acosArg)/pi;
$sunrise = $midseconds + (12-$timediff -$suntime -$longitude/15+$timezone) * 3600;
$sunset = $midseconds + (12-$timediff +$suntime -$longitude/15+$timezone) * 3600;

View File

@ -59,8 +59,10 @@ sub WOL_Set($@) {
;
}
WOL_UpdateReadings($hash);
RemoveInternalTimer($hash);
InternalTimer(gettimeofday()+5, "WOL_UpdateReadings", $hash, 0);
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "WOL_UpdateReadings", $hash, 0);
if ($hash->{STATE} eq "on") {
WOL_GetUpdate($hash);