2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 08:11:44 +00:00

90_at.pm: fix modify with active alignTime (Forum #27970)

git-svn-id: https://svn.fhem.de/fhem/trunk@6785 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-10-18 11:49:02 +00:00
parent 8671dda84a
commit 606411832d

View File

@ -90,12 +90,21 @@ at_Define($$)
} else { } else {
$hash->{VOLATILE} = 1; # Write these entries to the statefile $hash->{VOLATILE} = 1; # Write these entries to the statefile
} }
$hash->{NTM} = $ntm if($rel eq "+" || $fn);
my $alTime = AttrVal($name, "alignTime", undef);
if(!$data{AT_RECOMPUTE} && $alTime) {
my $ret = at_adjustAlign($hash, $alTime);
return $ret if($ret);
} else {
$hash->{TRIGGERTIME} = $nt; $hash->{TRIGGERTIME} = $nt;
$hash->{TRIGGERTIME_FMT} = FmtDateTime($nt); $hash->{TRIGGERTIME_FMT} = FmtDateTime($nt);
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
InternalTimer($nt, "at_Exec", $hash, 0); InternalTimer($nt, "at_Exec", $hash, 0);
}
$hash->{NTM} = $ntm if($rel eq "+" || $fn);
$hash->{STATE} = AttrVal($name, "disable", undef) ? $hash->{STATE} = AttrVal($name, "disable", undef) ?
"disabled" : ("Next: ".FmtTime($nt)); "disabled" : ("Next: ".FmtTime($nt));
return undef; return undef;
@ -152,22 +161,16 @@ at_Exec($)
} }
sub sub
at_Attr(@) at_adjustAlign($$)
{ {
my ($cmd, $name, $attrName, $attrVal) = @_; my($hash, $attrVal) = @_;
my $do = 0;
my $hash = $defs{$name};
if($cmd eq "set" && $attrName eq "alignTime") {
return "alignTime needs a list of timespec parameters" if(!$attrVal);
my ($alErr, $alHr, $alMin, $alSec, undef) = GetTimeSpec($attrVal); my ($alErr, $alHr, $alMin, $alSec, undef) = GetTimeSpec($attrVal);
return "$name alignTime: $alErr" if($alErr); return "$hash->{NAME} alignTime: $alErr" if($alErr);
my ($tm, $command) = split("[ \t]+", $hash->{DEF}, 2); my ($tm, $command) = split("[ \t]+", $hash->{DEF}, 2);
$tm =~ m/^(\+)?(\*({\d+})?)?(.*)$/; $tm =~ m/^(\+)?(\*({\d+})?)?(.*)$/;
my ($rel, $rep, $cnt, $tspec) = ($1, $2, $3, $4); my ($rel, $rep, $cnt, $tspec) = ($1, $2, $3, $4);
return "startTimes: $name is not relative" if(!$rel); return "startTimes: $hash->{NAME} is not relative" if(!$rel);
my (undef, $hr, $min, $sec, undef) = GetTimeSpec($tspec); my (undef, $hr, $min, $sec, undef) = GetTimeSpec($tspec);
my $now = time(); my $now = time();
@ -186,6 +189,21 @@ at_Attr(@)
$hash->{TRIGGERTIME} = $ttime; $hash->{TRIGGERTIME} = $ttime;
$hash->{TRIGGERTIME_FMT} = FmtDateTime($ttime); $hash->{TRIGGERTIME_FMT} = FmtDateTime($ttime);
$hash->{STATE} = "Next: " . FmtTime($ttime); $hash->{STATE} = "Next: " . FmtTime($ttime);
return undef;
}
sub
at_Attr(@)
{
my ($cmd, $name, $attrName, $attrVal) = @_;
my $do = 0;
my $hash = $defs{$name};
if($cmd eq "set" && $attrName eq "alignTime") {
return "alignTime needs a list of timespec parameters" if(!$attrVal);
my $ret = at_adjustAlign($hash, $attrVal);
return $ret if($ret);
} }
if($cmd eq "set" && $attrName eq "disable") { if($cmd eq "set" && $attrName eq "disable") {