mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 05:06:35 +00:00
Correct one-time relative at after reboot
git-svn-id: https://svn.fhem.de/fhem/trunk@1717 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4f9946d45f
commit
5b651554ac
@ -53,6 +53,7 @@
|
||||
- feature: motd with SecurityCheck added
|
||||
- feature: telnet module added, attr global port moved. allowfrom changed.
|
||||
- feature: FhemUtils/release.pm for the new update process added. (M. Fischer)
|
||||
- bugfix: correct one-time relative at commands after reboot
|
||||
|
||||
- 2011-12-31 (5.2)
|
||||
- bugfix: applying smallscreen attributes to firefox/opera
|
||||
|
@ -15,6 +15,7 @@ at_Initialize($)
|
||||
$hash->{DefFn} = "at_Define";
|
||||
$hash->{UndefFn} = "at_Undef";
|
||||
$hash->{AttrFn} = "at_Attr";
|
||||
$hash->{StateFn} = "at_State";
|
||||
$hash->{AttrList} = "disable:0,1 skip_next:0,1 loglevel:0,1,2,3,4,5,6 ".
|
||||
"alignTime";
|
||||
}
|
||||
@ -176,4 +177,31 @@ at_Attr(@)
|
||||
return undef;
|
||||
}
|
||||
|
||||
#############
|
||||
# Adjust one-time relative at's after reboot, the execution time is stored as
|
||||
# state
|
||||
sub
|
||||
at_State($$$$)
|
||||
{
|
||||
my ($hash, $tim, $vt, $val) = @_;
|
||||
|
||||
return undef if($hash->{DEF} !~ m/^\+\d/ ||
|
||||
$val !~ m/Next: (\d\d):(\d\d):(\d\d)/);
|
||||
|
||||
my ($h, $m, $s) = ($1, $2, $3);
|
||||
my $then = ($h*60+$m)*60+$s;
|
||||
my $now = time();
|
||||
my @lt = localtime($now);
|
||||
my $ntime = ($lt[2]*60+$lt[1])*60+$lt[0];
|
||||
return undef if($ntime > $then);
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
RemoveInternalTimer($name);
|
||||
InternalTimer($now+$then-$ntime, "at_Exec", $name, 0);
|
||||
$hash->{NTM} = "$h:$m:$s";
|
||||
$hash->{STATE} = $val;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
13
fhem/fhem.pl
13
fhem/fhem.pl
@ -1746,7 +1746,6 @@ CommandSetstate($$)
|
||||
my @a = split(" ", $param, 2);
|
||||
return "Usage: setstate <name> <state>\n$namedef" if(@a != 2);
|
||||
|
||||
|
||||
my @rets;
|
||||
foreach my $sdev (devspec2array($a[0])) {
|
||||
if(!defined($defs{$sdev})) {
|
||||
@ -1760,7 +1759,8 @@ CommandSetstate($$)
|
||||
if($a[1] =~ m/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) +([^ ].*)$/) {
|
||||
my ($tim, $nameval) = ($1, $2);
|
||||
my ($sname, $sval) = split(" ", $nameval, 2);
|
||||
(undef, $sval) = ReplaceEventMap($d, [$d, $sval], 0) if($attr{$d}{eventMap});
|
||||
(undef, $sval) = ReplaceEventMap($sdev, [$sdev, $sval], 0)
|
||||
if($attr{$sdev}{eventMap});
|
||||
my $ret = CallFn($sdev, "StateFn", $d, $tim, $sname, $sval);
|
||||
if($ret) {
|
||||
push @rets, $ret;
|
||||
@ -1779,9 +1779,16 @@ CommandSetstate($$)
|
||||
|
||||
# This time is not the correct one, but we do not store a timestamp for
|
||||
# this reading.
|
||||
$oldvalue{$sdev}{TIME} = TimeNow();
|
||||
my $tn = TimeNow();
|
||||
$oldvalue{$sdev}{TIME} = $tn;
|
||||
$oldvalue{$sdev}{VAL} = $d->{STATE};
|
||||
|
||||
my $ret = CallFn($sdev, "StateFn", $d, $tn, "STATE", $a[1]);
|
||||
if($ret) {
|
||||
push @rets, $ret;
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return join("\n", @rets);
|
||||
|
Loading…
x
Reference in New Issue
Block a user