mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-20 13:26:02 +00:00
Fritzbox: waiting for NTP
git-svn-id: https://svn.fhem.de/fhem/trunk@914 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
40715c0319
commit
75d0b40703
25
fhem/fhem.pl
25
fhem/fhem.pl
@ -167,7 +167,7 @@ my $nextat; # Time when next timer will be triggered.
|
|||||||
my $intAtCnt=0;
|
my $intAtCnt=0;
|
||||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||||
my $duplidx=0; # helper for the above pool
|
my $duplidx=0; # helper for the above pool
|
||||||
my $cvsid = '$Id: fhem.pl,v 1.142 2011-06-05 11:23:03 rudolfkoenig Exp $';
|
my $cvsid = '$Id: fhem.pl,v 1.143 2011-06-12 10:51:57 rudolfkoenig Exp $';
|
||||||
my $namedef =
|
my $namedef =
|
||||||
"where <name> is either:\n" .
|
"where <name> is either:\n" .
|
||||||
"- a single device name\n" .
|
"- a single device name\n" .
|
||||||
@ -176,7 +176,6 @@ my $namedef =
|
|||||||
"- a range seperated by dash (-)\n";
|
"- a range seperated by dash (-)\n";
|
||||||
my $stt_sec; # Used by SecondsTillTomorrow()
|
my $stt_sec; # Used by SecondsTillTomorrow()
|
||||||
my $stt_day; # Used by SecondsTillTomorrow()
|
my $stt_day; # Used by SecondsTillTomorrow()
|
||||||
my $lastTime; # Call rereadcfg if the time is set vie NTP.
|
|
||||||
|
|
||||||
$init_done = 0;
|
$init_done = 0;
|
||||||
|
|
||||||
@ -298,6 +297,12 @@ if($attr{global}{logfile} ne "-" && !$attr{global}{nofork}) {
|
|||||||
exit(0) if $pid;
|
exit(0) if $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# FritzBox special: Wait until the time is set via NTP,
|
||||||
|
# but no more then 2 hours
|
||||||
|
while(time() < 2*3600) {
|
||||||
|
sleep(5);
|
||||||
|
}
|
||||||
|
|
||||||
my $ret = CommandInclude(undef, $attr{global}{configfile});
|
my $ret = CommandInclude(undef, $attr{global}{configfile});
|
||||||
Log 1, "configfile: $ret" if($ret);
|
Log 1, "configfile: $ret" if($ret);
|
||||||
die("No port specified in the configfile.\n") if(!$server);
|
die("No port specified in the configfile.\n") if(!$server);
|
||||||
@ -685,7 +690,9 @@ AnalyzeCommand($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($cmd =~ m/^"(.*)"$/s) { # Shell code in bg, to be able to call us from it
|
if($cmd =~ m/^"(.*)"$/s) { # Shell code in bg, to be able to call us from it
|
||||||
system("$1 &");
|
my $out = "";
|
||||||
|
$out = "> $currlogfile 2>&1" if($currlogfile ne "-");
|
||||||
|
system("$1 $out &");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,6 +822,7 @@ CommandInclude($$)
|
|||||||
$rcvdquit = 0;
|
$rcvdquit = 0;
|
||||||
while(my $l = <$fh>) {
|
while(my $l = <$fh>) {
|
||||||
$l =~ s/[\r\n]//g;
|
$l =~ s/[\r\n]//g;
|
||||||
|
|
||||||
if($l =~ m/^(.*)\\ *$/) { # Multiline commands
|
if($l =~ m/^(.*)\\ *$/) { # Multiline commands
|
||||||
$bigcmd .= "$1\\\n";
|
$bigcmd .= "$1\\\n";
|
||||||
} else {
|
} else {
|
||||||
@ -823,6 +831,7 @@ CommandInclude($$)
|
|||||||
$bigcmd = "";
|
$bigcmd = "";
|
||||||
}
|
}
|
||||||
last if($rcvdquit);
|
last if($rcvdquit);
|
||||||
|
|
||||||
}
|
}
|
||||||
close($fh);
|
close($fh);
|
||||||
return join("\n", @ret) if(@ret);
|
return join("\n", @ret) if(@ret);
|
||||||
@ -1820,16 +1829,6 @@ HandleTimeout()
|
|||||||
return undef if(!$nextat);
|
return undef if(!$nextat);
|
||||||
|
|
||||||
my $now = gettimeofday();
|
my $now = gettimeofday();
|
||||||
|
|
||||||
# The following is FritzBox special: it does not have an RTC,
|
|
||||||
# and the time is set via NTP well after the fhem startup,
|
|
||||||
# so that all at commands should be recalculated
|
|
||||||
if($lastTime && abs($now - $lastTime) > 86400) {
|
|
||||||
Log 1, "Time shift, calling rereadcfg";
|
|
||||||
CommandRereadCfg(undef, undef);
|
|
||||||
}
|
|
||||||
$lastTime = $now;
|
|
||||||
|
|
||||||
return ($nextat-$now) if($now < $nextat);
|
return ($nextat-$now) if($now < $nextat);
|
||||||
|
|
||||||
$nextat = 0;
|
$nextat = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user