From 1c8d331eebd0b50763dacf036c394d7809dc5359 Mon Sep 17 00:00:00 2001
From: damian-s <>
Date: Sat, 1 Nov 2014 11:43:38 +0000
Subject: [PATCH] timing problem fixed: now gettimeofday used instead localtime
git-svn-id: https://svn.fhem.de/fhem/trunk@6848 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/98_DOIF.pm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm
index 5cb0e7918..0ecf631f6 100644
--- a/fhem/FHEM/98_DOIF.pm
+++ b/fhem/FHEM/98_DOIF.pm
@@ -473,7 +473,8 @@ DOIF_CheckCond($$)
{
my ($hash,$condition) = @_;
my $err="";
- my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime;
+ my ($seconds, $microseconds) = gettimeofday();
+ my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime($seconds);
my $hms = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
my $hm = sprintf("%02d:%02d", $hour, $min);
my $device;
@@ -635,7 +636,8 @@ DOIF_SetTimer($$)
my ($err, $h, $m, $s, $fn) = GetTimeSpec($timeStr);
return $err if($err);
my $second = $h*3600+$m*60+$s;
- my $now = time();
+ #my $now = time();
+ my ($now, $microseconds) = gettimeofday();
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
my $isdst_now=$isdst;
my $sec_today = $hour*3600+$min*60+$sec;
@@ -682,7 +684,8 @@ DOIF_SetSleepTimer($$$$$)
if ($hash->{helper}{sleeptimer} == -1 and ($last_cond != $nr or AttrVal($pn,"do","") eq "always")) {
my @sleeptimer=split(/:/,AttrVal($pn,"wait",""));
if ($sleeptimer[$nr]) {
- my $next_time = time()+$sleeptimer[$nr];
+ my ($seconds, $microseconds) = gettimeofday();
+ my $next_time = $seconds+$sleeptimer[$nr];
$hash->{helper}{sleeptimer}=$nr;
$hash->{helper}{sleepdevice}=$device;
my $cmd_nr=$nr+1;
@@ -1070,7 +1073,7 @@ Zeitintervalle über mehrere Tage müssen als Zeitpunkte angegeben werden, z. B.
Schalten bei Sonnenaufgang und Sonnenuntergang:
-define di_light DOIF ([{sunset(0,"17:00","21:00")}-{sunset_abs()}]) (set outdoorlight off) DOELSE (set outdoorlight on)
+define di_light DOIF ([{sunrise_abs()}-{sunset(1800,"17:00","21:00")}])(set outdoorlight off) DOELSE (set outdoorlight on)
Kombination von Ereignis- und Zeitsteuerung mit logischen Abfragen