mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fhem.pl: add -silent to the attr command (Forum #57691)
git-svn-id: https://svn.fhem.de/fhem/trunk@24261 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
123f68c620
commit
0baaa2ea44
@ -716,7 +716,7 @@ The following local attributes are used by a wider range of devices:
|
|||||||
<a name="attr"></a>
|
<a name="attr"></a>
|
||||||
<h3>attr</h3>
|
<h3>attr</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<code>attr [-a] [-r] <devspec> <attrname> [<value>]</code>
|
<code>attr [-a|-r|-silent] <devspec> <attrname> [<value>]</code>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<br>Set an attribute for a device defined by <a href="#define">define</a>.
|
<br>Set an attribute for a device defined by <a href="#define">define</a>.
|
||||||
@ -734,6 +734,7 @@ The following local attributes are used by a wider range of devices:
|
|||||||
space will be added automatically to the old value before appending the
|
space will be added automatically to the old value before appending the
|
||||||
new.<br>
|
new.<br>
|
||||||
With the -r option one can remove a part of an attribute value.<br>
|
With the -r option one can remove a part of an attribute value.<br>
|
||||||
|
With the -silent option the command is not recorded in the "save -?" list.<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@ -1059,8 +1060,8 @@ The following local attributes are used by a wider range of devices:
|
|||||||
case of a notify type definition, only the regex part will be changed. All
|
case of a notify type definition, only the regex part will be changed. All
|
||||||
other values (state, attributes, etc) will remain intact.
|
other values (state, attributes, etc) will remain intact.
|
||||||
After modify, the global event "MODIFIED" will be generated.<br>
|
After modify, the global event "MODIFIED" will be generated.<br>
|
||||||
With the -silent option the command is not recorded in the "save -?" list.
|
With the -silent option the command is not recorded in the "save -?" list.<br>
|
||||||
<br><br>
|
<br>
|
||||||
Example:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
<code>define lampon at 19:00 set lamp on</code><br>
|
<code>define lampon at 19:00 set lamp on</code><br>
|
||||||
|
@ -725,7 +725,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
<a name="attr"></a>
|
<a name="attr"></a>
|
||||||
<h3>attr</h3>
|
<h3>attr</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<code>attr [-a] [-r] <devspec> <attrname> [<value>]</code>
|
<code>attr [-a|-r|-silent] <devspec> <attrname> [<value>]</code>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -749,6 +749,8 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
anfängt, dann wird es mit einem Leerzeichen angehängt.
|
anfängt, dann wird es mit einem Leerzeichen angehängt.
|
||||||
<br>
|
<br>
|
||||||
Mit der -r Option kann man Teile eines Attributes wieder entfernen.<br>
|
Mit der -r Option kann man Teile eines Attributes wieder entfernen.<br>
|
||||||
|
Mit der silent Option wird der Befehl nicht in die "save -?" Liste
|
||||||
|
eingetragen.<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
Beispiele:
|
Beispiele:
|
||||||
@ -1117,9 +1119,9 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
Werte (Stati, Attribute, etc) bleiben erhalten.<br>
|
Werte (Stati, Attribute, etc) bleiben erhalten.<br>
|
||||||
Nach modify wird das global MODIFIED Event erzeugt.<br>
|
Nach modify wird das global MODIFIED Event erzeugt.<br>
|
||||||
Nach der Durchführung das globale Ereignis "MODIFIED" wird generiert.<br>
|
Nach der Durchführung das globale Ereignis "MODIFIED" wird generiert.<br>
|
||||||
Mit der silent Option wird der modify Befehl nicht in die "save -?" Liste
|
Mit der silent Option wird der Befehl nicht in die "save -?" Liste
|
||||||
eingetragen.
|
eingetragen.<br>
|
||||||
<br><br>
|
<br>
|
||||||
|
|
||||||
Beispiel:
|
Beispiel:
|
||||||
<ul>
|
<ul>
|
||||||
|
15
fhem/fhem.pl
15
fhem/fhem.pl
@ -2950,13 +2950,14 @@ CommandAttr($$)
|
|||||||
{
|
{
|
||||||
my ($cl, $param) = @_;
|
my ($cl, $param) = @_;
|
||||||
my ($ret, $append, $remove, @a);
|
my ($ret, $append, $remove, @a);
|
||||||
|
my %opt;
|
||||||
|
my $optRegexp = '-a|-r|-silent';
|
||||||
|
$param = cmd_parseOpts($param, $optRegexp, \%opt);
|
||||||
|
|
||||||
$append = ($param =~ s/^-a //);
|
|
||||||
$remove = ($param =~ s/^-r //);
|
|
||||||
@a = split(" ", $param, 3) if($param);
|
@a = split(" ", $param, 3) if($param);
|
||||||
|
|
||||||
return "Usage: attr [-a|-r] <name> <attrname> [<attrvalue>]\n$namedef"
|
return "Usage: attr [$optRegexp] <name> <attrname> [<attrvalue>]\n$namedef"
|
||||||
if(@a < 2 || ($append && $remove));
|
if(@a < 2 || ($opt{a} && $opt{r}));
|
||||||
my $a1 = $a[1];
|
my $a1 = $a[1];
|
||||||
return "$a[0]: bad attribute name '$a1' (allowed chars: A-Za-z/\\d_\\.-)"
|
return "$a[0]: bad attribute name '$a1' (allowed chars: A-Za-z/\\d_\\.-)"
|
||||||
if($featurelevel > 5.9 && !goodReadingName($a1) && $a1 ne "?");
|
if($featurelevel > 5.9 && !goodReadingName($a1) && $a1 ne "?");
|
||||||
@ -2998,11 +2999,11 @@ CommandAttr($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($append && $attr{$sdev} && $attr{$sdev}{$attrName}) {
|
if($opt{a} && $attr{$sdev} && $attr{$sdev}{$attrName}) {
|
||||||
$attrVal = $attr{$sdev}{$attrName} .
|
$attrVal = $attr{$sdev}{$attrName} .
|
||||||
($attrVal =~ m/^,/ ? $attrVal : " $attrVal");
|
($attrVal =~ m/^,/ ? $attrVal : " $attrVal");
|
||||||
}
|
}
|
||||||
if($remove && $attr{$sdev} && $attr{$sdev}{$attrName}) {
|
if($opt{r} && $attr{$sdev} && $attr{$sdev}{$attrName}) {
|
||||||
my $v = $attr{$sdev}{$attrName};
|
my $v = $attr{$sdev}{$attrName};
|
||||||
$v =~ s/\b$attrVal\b//;
|
$v =~ s/\b$attrVal\b//;
|
||||||
$attrVal = $v;
|
$attrVal = $v;
|
||||||
@ -3118,7 +3119,7 @@ CommandAttr($$)
|
|||||||
evalStateFormat($hash);
|
evalStateFormat($hash);
|
||||||
}
|
}
|
||||||
addStructChange("attr", $sdev, "$sdev $attrName $attrVal")
|
addStructChange("attr", $sdev, "$sdev $attrName $attrVal")
|
||||||
if(!defined($oVal) || $oVal ne $attrVal);
|
if(!$opt{silent} && (!defined($oVal) || $oVal ne $attrVal));
|
||||||
DoTrigger("global", "ATTR $sdev $attrName $attrVal", 1) if($init_done);
|
DoTrigger("global", "ATTR $sdev $attrName $attrVal", 1) if($init_done);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user