2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 04:36:36 +00:00

fhem.pl: deleteattr attrname is a regexp now (Forum #114398)

git-svn-id: https://svn.fhem.de/fhem/trunk@22833 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-09-23 15:28:56 +00:00
parent cdba8fc554
commit 0fa0821105
3 changed files with 12 additions and 7 deletions

View File

@ -822,6 +822,8 @@ The following local attributes are used by a wider range of devices:
or all attributes for a device (if no <attrname> is defined).
See the <a href="#devspec">Device specification</a> section for details on
&lt;devspec&gt;.<br>
&lt;attrname&gt; is in fact a regexp, complemented with ^ and $ as usual, so
a range of attributes can be deleted with one command.<br>
After deleting the attribute, the global event "DELETEATTR" will be generated.
<br>

View File

@ -850,6 +850,8 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
kein &lt;attrname&gt; angegeben wird).<br>
Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a>
f&uuml;r Details der &lt;devspec&gt;.<br>
&lt;attrname&gt; ist ein Regexp, erg&auml;nzt mit ^ und $, damit eine Menge
von Attributen mit einem Befehl gel&ouml;scht werden kann.<br>
Nach der Durchf&uuml;hrung das globale Ereignis "DELETEATTR" wird generiert.
<br>

View File

@ -2319,17 +2319,18 @@ CommandDeleteAttr($$)
next;
}
if(@a == 1) {
if(@a == 1) { # Delete all attributes of a device
delete($attr{$sdev});
addStructChange("deleteAttr", $sdev, $sdev);
DoTrigger("global", "DELETEATTR $sdev", 1) if($init_done);
} else {
delete($attr{$sdev}{$a[1]}) if(defined($attr{$sdev}));
addStructChange("deleteAttr", $sdev, join(" ", @a));
DoTrigger("global", "DELETEATTR $sdev $a[1]", 1) if($init_done);
} else { # delete specified attribute(s)
if(defined($attr{$sdev})) {
map { delete($attr{$sdev}{$_}) if($_ =~ m/^$a[1]$/) }
keys %{$attr{$sdev}};
}
}
addStructChange("deleteAttr", $sdev, join(" ", @a));
DoTrigger("global", "DELETEATTR $sdev ".join(" ",@a), 1) if($init_done);
}