2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

59_Twilight: should solve the problem with daylightsavingtime

git-svn-id: https://svn.fhem.de/fhem/trunk@14039 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
orti-otto 2017-04-19 19:59:56 +00:00
parent b27510f57d
commit 34609ad49e

View File

@ -177,17 +177,17 @@ sub myRemoveInternalTimer($$) {
} }
} }
################################################################################ ################################################################################
sub myRemoveInternalTimerByName($){ #sub myRemoveInternalTimerByName($){
my ($name) = @_; # my ($name) = @_;
foreach my $a (keys %intAt) { # foreach my $a (keys %intAt) {
my $nam = ""; # my $nam = "";
my $arg = $intAt{$a}{ARG}; # my $arg = $intAt{$a}{ARG};
if (ref($arg) eq "HASH" && defined($arg->{NAME}) ) { # if (ref($arg) eq "HASH" && defined($arg->{NAME}) ) {
$nam = $arg->{NAME} if (ref($arg) eq "HASH" && defined($arg->{NAME}) ); # $nam = $arg->{NAME} if (ref($arg) eq "HASH" && defined($arg->{NAME}) );
} # }
delete($intAt{$a}) if($nam =~ m/^$name/g); # delete($intAt{$a}) if($nam =~ m/^$name/g);
} # }
} #}
################################################################################ ################################################################################
sub myGetHashIndirekt ($$) { sub myGetHashIndirekt ($$) {
my ($myHash, $function) = @_; my ($myHash, $function) = @_;
@ -206,37 +206,40 @@ sub Twilight_midnight_seconds($) {
return $secs; return $secs;
} }
################################################################################ ################################################################################
sub Twilight_ssTimeAsEpoch($) { #sub Twilight_ssTimeAsEpoch($) {
my ($zeit) = @_; # my ($zeit) = @_;
my ($hour, $min, $sec) = split(":",$zeit); # my ($hour, $min, $sec) = split(":",$zeit);
#
my $days=0; # my $days=0;
if ($hour>=24) {$days = 1; $hour -=24}; # if ($hour>=24) {$days = 1; $hour -=24};
#
my @jetzt_arr = localtime(time()); # my @jetzt_arr = localtime(time());
#Stunden Minuten Sekunden # #Stunden Minuten Sekunden
$jetzt_arr[2] = $hour; $jetzt_arr[1] = $min; $jetzt_arr[0] = $sec; # $jetzt_arr[2] = $hour; $jetzt_arr[1] = $min; $jetzt_arr[0] = $sec;
$jetzt_arr[3] += $days; # $jetzt_arr[3] += $days;
my $next = timelocal_nocheck(@jetzt_arr); # my $next = timelocal_nocheck(@jetzt_arr);
#
return $next; # return $next;
} #}
################################################################################ ################################################################################
sub Twilight_calc($$) { sub Twilight_calc($$) {
my ($deg, $idx) = @_; my ($deg, $idx) = @_;
my $midnight = time() - Twilight_midnight_seconds(time());
my $sr = sunrise_abs("Horizon=$deg"); my $sr = sunrise_abs("Horizon=$deg");
my $ss = sunset_abs ("Horizon=$deg"); my $ss = sunset_abs ("Horizon=$deg");
my ($srhour, $srmin, $srsec) = split(":",$sr); $srhour -= 24 if($srhour>=24); my ($srhour, $srmin, $srsec) = split(":",$sr); $srhour -= 24 if($srhour>=24);
my ($sshour, $ssmin, $sssec) = split(":",$ss); $sshour -= 24 if($sshour>=24); my ($sshour, $ssmin, $sssec) = split(":",$ss); $sshour -= 24 if($sshour>=24);
my $sr1 = 3600*$srhour+60*$srmin+$srsec; my $sr1 = $midnight + 3600*$srhour+60*$srmin+$srsec;
my $ss1 = 3600*$sshour+60*$ssmin+$sssec; my $ss1 = $midnight + 3600*$sshour+60*$ssmin+$sssec;
return (0,0) if (abs ($sr1 - $ss1) < 30); return (0,0) if (abs ($sr1 - $ss1) < 30);
return Twilight_ssTimeAsEpoch($sr) + 0.01*$idx, #return Twilight_ssTimeAsEpoch($sr) + 0.01*$idx,
Twilight_ssTimeAsEpoch($ss) - 0.01*$idx; # Twilight_ssTimeAsEpoch($ss) - 0.01*$idx;
return ($sr1 + 0.01*$idx), ($ss1 - 0.01*$idx);
} }
################################################################################ ################################################################################
sub Twilight_TwilightTimes(@) { sub Twilight_TwilightTimes(@) {
@ -413,7 +416,7 @@ sub Twilight_WeatherCallback(@) {
$result = undef; $result = undef;
} else { } else {
Log3 $hash, 4, "[$hash->{NAME}] got weather info from yahoo for $hash->{WEATHER}"; Log3 $hash, 4, "[$hash->{NAME}] got weather info from yahoo for $hash->{WEATHER}";
Log3 $hash, 4, "[$hash->{NAME}] answer=$result" if defined $result; Log3 $hash, 5, "[$hash->{NAME}] answer=$result" if defined $result;
} }
Twilight_getWeatherHorizon($hash, $result); Twilight_getWeatherHorizon($hash, $result);