diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html
index adbc65daf..3d1c06e1d 100644
--- a/fhem/docs/commandref_frame.html
+++ b/fhem/docs/commandref_frame.html
@@ -675,7 +675,7 @@ The following local attributes are used by a wider range of devices:
attr
- attr <devspec> <attrname> [<value>]
+ attr [-a|-r] <devspec> <attrname> [<value>]
Set an attribute for a device defined by define.
You can define your own attributes too to use them
@@ -685,19 +685,27 @@ The following local attributes are used by a wider range of devices:
See the Device specification section for details on
<devspec>.
After setting the attribute, the global event "ATTR" will be generated.
-
+
+ If the option -a is specified, append the given value to the currently
+ existing value. Note: if the value does not start with a comma (,), then a
+ space will be added automatically to the old value before appending the
+ new.
+ With the -r option one can remove a part of an attribute value.
+
Examples:
-
- attr global verbose 3
- attr lamp room kitchen
- attr lamp group lights
- attr lamp loglevel 6
- attr weatherstation event-on-update-reading wind,temperature,humidity
- attr weatherstation event-on-change-reading israining
- attr weatherstation event-on-change-reading israining,state
- attr heating stateFormat Temp:measured-temp, Valve:actuator
-
+
+ attr global verbose 3
+ attr lamp room kitchen
+ attr lamp group lights
+ attr lamp loglevel 6
+ attr weatherstation event-on-update-reading wind,temperature,humidity
+ attr weatherstation event-on-change-reading israining
+ attr weatherstation event-on-change-reading israining,state
+ attr heating stateFormat Temp:measured-temp, Valve:actuator
+ attr -a TYPE=SVG room ,SvgRoom
+ attr -r TYPE=SVG room ,SvgRoom
+
Notes:
diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html
index ac9dc4306..1427a974d 100644
--- a/fhem/docs/commandref_frame_DE.html
+++ b/fhem/docs/commandref_frame_DE.html
@@ -685,7 +685,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
attr
- attr <devspec> <attrname> [<value>]
+ attr [-a|-r] <devspec> <attrname> [<value>]
Dieser Befehl setzt ein Attribut für ein Gerät welches mit
+ Falls die Option -a spezifiziert ist, dann wird value zum aktuellen Wert
+ hinzugefügt. Achtung: falls value nicht mit einem Komma (,)
+ anfängt, dann wird es mit einem Leerzeichen angehängt.
+
+ Mit der -r Option kann man Teile eines Attributes wieder entfernen.
+
+
Beispiele:
-
- attr global verbose 3
- attr lamp room kitchen
- attr lamp group lights
- attr lamp loglevel 6
- attr weatherstation event-on-update-reading wind,temperature,humidity
- attr weatherstation event-on-change-reading israining
- attr weatherstation event-on-change-reading israining,state
- attr heating stateFormat Temp:measured-temp, Valve:actuator
-
+
+ attr global verbose 3
+ attr lamp room kitchen
+ attr lamp group lights
+ attr lamp loglevel 6
+ attr weatherstation event-on-update-reading wind,temperature,humidity
+ attr weatherstation event-on-change-reading israining
+ attr weatherstation event-on-change-reading israining,state
+ attr heating stateFormat Temp:measured-temp, Valve:actuator
+ attr -a TYPE=SVG room ,SvgRoom
+ attr -r TYPE=SVG room ,SvgRoom
+
Bemerkungen:
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 66b1d8eb2..3416244c2 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -2668,11 +2668,13 @@ sub
CommandAttr($$)
{
my ($cl, $param) = @_;
- my ($ret, @a);
+ my ($ret, $append, $remove, @a);
+ $append = ($param =~ s/^-a //);
+ $remove = ($param =~ s/^-r //);
@a = split(" ", $param, 3) if($param);
- return "Usage: attr []\n$namedef"
+ return "Usage: attr [-a|-r] []\n$namedef"
if(@a && @a < 2);
my @rets;
@@ -2680,6 +2682,7 @@ CommandAttr($$)
my $hash = $defs{$sdev};
my $attrName = $a[1];
+ my $attrVal = $a[2];
if(!defined($hash)) {
push @rets, "Please define $sdev first" if($init_done);#define -ignoreErr
next;
@@ -2710,15 +2713,25 @@ CommandAttr($$)
}
}
- if($attrName eq 'disable' and $a[2] && $a[2] eq 'toggle') {
- $a[2] = IsDisabled($sdev) ? 0 : 1;
+ if($append && $attrVal && $attr{$sdev} && $attr{$sdev}{$attrName}) {
+ $attrVal = $attr{$sdev}{$attrName} .
+ ($attrVal =~ m/^,/ ? $attrVal : " $attrVal");
+ }
+ if($remove && $attrVal && $attr{$sdev} && $attr{$sdev}{$attrName}) {
+ my $v = $attr{$sdev}{$attrName};
+ $v =~ s/\s*$attrVal\s*//;
+ $attrVal = $v;
+ }
+
+ if($attrName eq 'disable' and $attrVal && $attrVal eq 'toggle') {
+ $attrVal = IsDisabled($sdev) ? 0 : 1;
}
if($attrName eq "userReadings") {
my @userReadings;
# myReading1[:trigger1] [modifier1] { codecodecode1 }, ...
- my $arg= $a[2];
+ my $arg= $attrVal;
# matches myReading1[:trigger2] { codecode1 }
my $regexi= '\s*([\w.-]+)(:\S*)?\s+((\w+)\s+)?({.*?})\s*';
@@ -2755,7 +2768,7 @@ CommandAttr($$)
if($attrName eq "eventMap") {
delete $hash->{".eventMapHash"};
delete $hash->{".eventMapCmd"};
- $attr{$sdev}{eventMap} = (defined $a[2] ? $a[2] : 1);
+ $attr{$sdev}{eventMap} = (defined $attrVal ? $attrVal : 1);
my $r = ReplaceEventMap($sdev, "test", 1); # refresh eventMapCmd
if($r =~ m/^ERROR in eventMap for /) {
delete($attr{$sdev}{eventMap});
@@ -2773,11 +2786,11 @@ CommandAttr($$)
pv=>{"%name"=>1, "%state"=>1, "%type"=>1} },
);
- if(defined($a[2]) && $ra{$attrName} && $init_done) {
- my ($lval,$rp) = ($a[2], $ra{$attrName}{p});
+ if(defined($attrVal) && $ra{$attrName} && $init_done) {
+ my ($lval,$rp) = ($attrVal, $ra{$attrName}{p});
if($rp && $lval =~ m/$rp/) {
- my $err = perlSyntaxCheck($a[2], %{$ra{$attrName}{pv}});
+ my $err = perlSyntaxCheck($attrVal, %{$ra{$attrName}{pv}});
return "attr $sdev $a[1]: $err" if($err);
} else {
@@ -2792,8 +2805,8 @@ CommandAttr($$)
}
if($fhemdebug && $sdev eq "global") {
- $a[2] = "-" if($attrName eq "logfile");
- $a[2] = 5 if($attrName eq "verbose");
+ $attrVal = "-" if($attrName eq "logfile");
+ $attrVal = 5 if($attrName eq "verbose");
}
$ret = CallFn($sdev, "AttrFn", "set", @a);
if($ret) {
@@ -2801,27 +2814,27 @@ CommandAttr($$)
next;
}
- my $val = $a[2];
+ my $val = $attrVal;
$val = 1 if(!defined($val));
$attr{$sdev}{$attrName} = $val;
if($attrName eq "IODev") {
- if(!$a[2] || !defined($defs{$a[2]})) {
+ if(!$attrVal || !defined($defs{$attrVal})) {
if($init_done) {
- push @rets,"$sdev: unknown IODev $a[2] specified";
+ push @rets,"$sdev: unknown IODev $attrVal specified";
} else {
$hash->{IODevMissing} = 1;
- $hash->{IODevName} = $a[2];
+ $hash->{IODevName} = $attrVal;
}
next;
}
- my $ioname = $a[2];
+ my $ioname = $attrVal;
$hash->{IODev} = $defs{$ioname};
delete($defs{$ioname}{".clientArray"}); # Force a recompute
}
if($attrName eq "stateFormat" && $init_done) {
- my $err = perlSyntaxCheck($a[2], ("%name"=>""));
+ my $err = perlSyntaxCheck($attrVal, ("%name"=>""));
return $err if($err);
evalStateFormat($hash);
}