2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

fhem.pl: another fix for attr -a/-r (Forum #109678)

git-svn-id: https://svn.fhem.de/fhem/trunk@21548 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-03-30 20:37:31 +00:00
parent 9b4bc88369
commit f9f0a6d62e

View File

@ -2873,7 +2873,7 @@ CommandAttr($$)
@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 [-a|-r] <name> <attrname> [<attrvalue>]\n$namedef"
if(@a < 2); if(@a < 2 || ($append && $remove));
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 "?");
@ -2917,12 +2917,11 @@ CommandAttr($$)
if($append && $attr{$sdev} && $attr{$sdev}{$attrName}) { if($append && $attr{$sdev} && $attr{$sdev}{$attrName}) {
$attrVal = $attr{$sdev}{$attrName} . $attrVal = $attr{$sdev}{$attrName} .
($attrVal =~ m/^,/ ? $attrVal : " $attrVal"); ($attrVal =~ m/^,/ ? $attrVal : " $attrVal");
}
} elsif($remove && $attr{$sdev} && $attr{$sdev}{$attrName}) { if($remove && $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;
} }
if($attrName eq 'disable' && $attrVal eq 'toggle') { if($attrName eq 'disable' && $attrVal eq 'toggle') {