diff --git a/fhem/FHEM/90_at.pm b/fhem/FHEM/90_at.pm index a1803a2b7..c964ed045 100755 --- a/fhem/FHEM/90_at.pm +++ b/fhem/FHEM/90_at.pm @@ -110,8 +110,9 @@ at_Define($$) RemoveInternalTimer($hash); InternalTimer($nt, "at_Exec", $hash, 0); $hash->{NTM} = $ntm if($rel eq "+" || $fn); - my $val = AttrVal($name, "disable", undef) ? - "disabled" : ("Next: ".FmtTime($nt)); + my $val = IsDisabled($name) ? + (AttrVal($name, "disable", undef) ? "disabled" : "inactive") : + ("Next: ".FmtTime($nt)); readingsSingleUpdate($hash, "state", $val, 1); } @@ -206,22 +207,36 @@ at_Set($@) { my ($hash, @a) = @_; - my $cmd = ($at_detailFnCalled ? "modifyTimeSpec" : "modifyTimeSpec:time"); + my %sets = (modifyTimeSpec=>1, inactive=>0, active=>0); + my $cmd = join(" ", sort keys %sets); + $cmd =~ s/modifyTimeSpec/modifyTimeSpec:time/ if($at_detailFnCalled); $at_detailFnCalled = 0; return "no set argument specified" if(int(@a) < 2); return "Unknown argument $a[1], choose one of $cmd" - if($a[1] ne "modifyTimeSpec"); + if(!defined($sets{$a[1]})); + + if($a[1] eq "modifyTimeSpec") { + my ($err, undef) = GetTimeSpec($a[2]); + return $err if($err); - my ($err, undef) = GetTimeSpec($a[2]); - return $err if($err); + my $def = ($hash->{RELATIVE} eq "yes" ? "+":""). + ($hash->{PERIODIC} eq "yes" ? "*":""). + $a[2]; + $hash->{OLDDEF} = $hash->{DEF}; + my $ret = at_Define($hash, "$hash->{NAME} at $def"); + delete $hash->{OLDDEF}; + return $ret; + + } elsif($a[1] eq "inactive") { + readingsSingleUpdate($hash, "state", "inactive", 1); + return undef; + + } elsif($a[1] eq "active") { + readingsSingleUpdate($hash,"state","Next: ".FmtTime($hash->{TRIGGERTIME}),1) + if(!AttrVal($hash->{NAME}, "disable", undef)); + return undef; + } - my $def = ($hash->{RELATIVE} eq "yes" ? "+":""). - ($hash->{PERIODIC} eq "yes" ? "*":""). - $a[2]; - $hash->{OLDDEF} = $hash->{DEF}; - my $ret = at_Define($hash, "$hash->{NAME} at $def"); - delete $hash->{OLDDEF}; - return $ret; } sub @@ -257,6 +272,11 @@ at_State($$$$) { my ($hash, $tim, $vt, $val) = @_; + if($vt eq "state" && $val eq "inactive") { + readingsSingleUpdate($hash, "state", "inactive", 1); + return undef; + } + return undef if($hash->{DEF} !~ m/^\+\d/ || $val !~ m/Next: (\d\d):(\d\d):(\d\d)/); @@ -437,8 +457,17 @@ EOF Change the execution time. Note: the N-times repetition is ignored. It is intended to be used in combination with webCmd, for an easier modification from the room - overview in FHEMWEB. + overview in FHEMWEB. +
  • inactive
    + Inactivates the current device. Note the slight difference to the + disable attribute: using set inactive the state is automatically saved + to the statefile on shutdown, there is no explicit save necesary.
    + This command is intended to be used by scripts to temporarily + deactivate the at.
    + The concurrent setting of the disable attribute is not recommended.
  • +
  • active
    + Activates the current device (see inactive).

  • @@ -488,7 +517,6 @@ EOF
    - =end html @@ -593,6 +621,18 @@ EOF Modifikation im FHEMWEB Raumübersicht, dazu muss man modifyTimeSpec in webCmd spezifizieren. +
  • inactive
    + Deaktiviert das entsprechende Gerät. Beachte den leichten + semantischen Unterschied zum disable Attribut: "set inactive" + wird bei einem shutdown automatisch in fhem.state gespeichert, es ist + kein save notwendig.
    + Der Einsatzzweck sind Skripte, um das at temporär zu + deaktivieren.
    + Das gleichzeitige Verwenden des disable Attributes wird nicht empfohlen. +
  • +
  • active
    + Aktiviert das entsprechende Gerät, siehe inactive. +

  • @@ -604,7 +644,7 @@ EOF