mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 22:56:34 +00:00
notify/at: introduce the set inactive/active parameters (Forum #34603)
git-svn-id: https://svn.fhem.de/fhem/trunk@8165 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0853267e35
commit
ffc3543d89
@ -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
|
||||
<a href="#webCmd">webCmd</a>, for an easier modification from the room
|
||||
overview in FHEMWEB.
|
||||
overview in FHEMWEB.</li>
|
||||
<li>inactive<br>
|
||||
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.<br>
|
||||
This command is intended to be used by scripts to temporarily
|
||||
deactivate the at.<br>
|
||||
The concurrent setting of the disable attribute is not recommended.
|
||||
</li>
|
||||
<li>active<br>
|
||||
Activates the current device (see inactive).</li>
|
||||
</ul><br>
|
||||
|
||||
|
||||
@ -488,7 +517,6 @@ EOF
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
</ul>
|
||||
|
||||
=end html
|
||||
@ -593,6 +621,18 @@ EOF
|
||||
Modifikation im FHEMWEB Raumübersicht, dazu muss man
|
||||
modifyTimeSpec in <a href="webCmd">webCmd</a> spezifizieren.
|
||||
</li>
|
||||
<li>inactive<br>
|
||||
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.<br>
|
||||
Der Einsatzzweck sind Skripte, um das at temporär zu
|
||||
deaktivieren.<br>
|
||||
Das gleichzeitige Verwenden des disable Attributes wird nicht empfohlen.
|
||||
</li>
|
||||
<li>active<br>
|
||||
Aktiviert das entsprechende Gerät, siehe inactive.
|
||||
</li>
|
||||
</ul><br>
|
||||
|
||||
|
||||
@ -604,7 +644,7 @@ EOF
|
||||
<ul>
|
||||
<a name="disable"></a>
|
||||
<li>disable<br>
|
||||
Deaktiviert das entsprechende Ger&aauml;t.<br>
|
||||
Deaktiviert das entsprechende Gerät.<br>
|
||||
Hinweis: Wenn angewendet auf ein <a href="#at">at</a>, dann wird der
|
||||
Befehl nicht ausgeführt, jedoch die nächste
|
||||
Ausführungszeit berechnet.</li><br>
|
||||
|
@ -17,6 +17,7 @@ notify_Initialize($)
|
||||
$hash->{AttrFn} = "notify_Attr";
|
||||
$hash->{AttrList} = "disable:0,1 disabledForIntervals forwardReturnValue:0,1 showtime:0,1 addStateEvent:0,1";
|
||||
$hash->{SetFn} = "notify_Set";
|
||||
$hash->{StateFn} = "notify_State";
|
||||
$hash->{FW_detailFn} = "notify_fhemwebFn";
|
||||
}
|
||||
|
||||
@ -125,7 +126,7 @@ notify_Set($@)
|
||||
my $me = $hash->{NAME};
|
||||
|
||||
return "no set argument specified" if(int(@a) < 2);
|
||||
my %sets = (addRegexpPart=>2, removeRegexpPart=>1);
|
||||
my %sets = (addRegexpPart=>2, removeRegexpPart=>1, inactive=>0, active=>0);
|
||||
|
||||
my $cmd = $a[1];
|
||||
return "Unknown argument $cmd, choose one of " # No dropdown in FHEMWEB
|
||||
@ -159,7 +160,26 @@ notify_Set($@)
|
||||
$hash->{DEF} = "$re ".$hash->{".COMMAND"};
|
||||
notifyRegexpChanged($hash, $re);
|
||||
|
||||
} elsif($cmd eq "inactive") {
|
||||
readingsSingleUpdate($hash, "state", "inactive", 1);
|
||||
|
||||
}
|
||||
elsif($cmd eq "active") {
|
||||
readingsSingleUpdate($hash, "state", "active", 1)
|
||||
if(!AttrVal($me, "disable", undef));
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
#############
|
||||
sub
|
||||
notify_State($$$$)
|
||||
{
|
||||
my ($hash, $tim, $vt, $val) = @_;
|
||||
|
||||
return undef if($vt ne "state" || $val ne "inactive");
|
||||
readingsSingleUpdate($hash, "state", "inactive", 1);
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -331,22 +351,24 @@ notify_fhemwebFn($$$$)
|
||||
<a name="notifyset"></a>
|
||||
<b>Set </b>
|
||||
<ul>
|
||||
<li>addRegexpPart <device> <regexp>
|
||||
<ul>
|
||||
<li>addRegexpPart <device> <regexp><br>
|
||||
add a regexp part, which is constructed as device:regexp. The parts
|
||||
are separated by |. Note: as the regexp parts are resorted, manually
|
||||
constructed regexps may become invalid.
|
||||
</ul>
|
||||
</li>
|
||||
<li>removeRegexpPart <re>
|
||||
<ul>
|
||||
constructed regexps may become invalid. </li>
|
||||
<li>removeRegexpPart <re><br>
|
||||
remove a regexp part. Note: as the regexp parts are resorted, manually
|
||||
constructed regexps may become invalid.<br>
|
||||
The inconsistency in addRegexpPart/removeRegexPart arguments originates
|
||||
from the reusage of javascript functions.
|
||||
</ul>
|
||||
</li>
|
||||
<br>
|
||||
from the reusage of javascript functions.</li>
|
||||
<li>inactive<br>
|
||||
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.<br>
|
||||
This command is intended to be used by scripts to temporarily
|
||||
deactivate the notify.<br>
|
||||
The concurrent setting of the disable attribute is not recommended.</li>
|
||||
<li>active<br>
|
||||
Activates the current device (see inactive).</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -520,19 +542,27 @@ notify_fhemwebFn($$$$)
|
||||
<a name="notifyset"></a>
|
||||
<b>Set </b>
|
||||
<ul>
|
||||
<li>addRegexpPart <device> <regexp>
|
||||
<ul>
|
||||
<li>addRegexpPart <device> <regexp><br>
|
||||
Fügt ein regexp Teil hinzu, der als device:regexp aufgebaut ist.
|
||||
Die Teile werden nach Regexp-Regeln mit | getrennt. Achtung: durch
|
||||
hinzufügen können manuell erzeugte Regexps ungültig
|
||||
werden.
|
||||
</ul></li>
|
||||
<li>removeRegexpPart <re>
|
||||
<ul>
|
||||
werden.</li>
|
||||
<li>removeRegexpPart <re><br>
|
||||
Entfernt ein regexp Teil. Die Inkonsistenz von addRegexpPart /
|
||||
removeRegexPart-Argumenten hat seinen Ursprung in der Wiederverwendung
|
||||
von Javascript-Funktionen.
|
||||
</ul></li>
|
||||
von Javascript-Funktionen.</li>
|
||||
<li>inactive<br>
|
||||
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.<br>
|
||||
Der Einsatzzweck sind Skripte, um das notify temporär zu
|
||||
deaktivieren.<br>
|
||||
Das gleichzeitige Verwenden des disable Attributes wird nicht empfohlen.
|
||||
</li>
|
||||
<li>active<br>
|
||||
Aktiviert das entsprechende Gerät, siehe inactive.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
@ -695,6 +695,8 @@ IsDisabled($)
|
||||
return 0 if(!$devname || !defined($attr{$devname}));
|
||||
|
||||
return 1 if($attr{$devname}{disable});
|
||||
return 1 if($defs{$devname} && $defs{$devname}{STATE} &&
|
||||
$defs{$devname}{STATE} eq "inactive");
|
||||
|
||||
my $dfi = $attr{$devname}{disabledForIntervals};
|
||||
if(defined($dfi)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user