mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fhem.pl: add i:/r:/a: to devspec (Forum #45801)
git-svn-id: https://svn.fhem.de/fhem/trunk@10208 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a41f1ecaab
commit
f0ea2ff125
@ -308,9 +308,11 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<li>a single device name. This is the most common case.</li>
|
||||
<li>a list of devices, separated by comma (,)</li>
|
||||
<li>a regular expression</li>
|
||||
<li>a NAME=VALUE pair, where NAME can be an Internal value like TYPE, a
|
||||
<li>a NAME=VALUE pair, where NAME can be an internal value like TYPE, a
|
||||
Reading-Name or an attribute. VALUE is a regexp. To negate the
|
||||
comparison, use NAME!=VALUE</li>
|
||||
comparison, use NAME!=VALUE. To restrict the search, use i: as prefix
|
||||
for internal values, r: for readings and a: for attributes. See the
|
||||
example below.</li>
|
||||
<li>if the spec is followed by the expression :FILTER=NAME=VALUE, then the
|
||||
values found in the first round are filtered by the second expression.
|
||||
</ul>
|
||||
@ -324,6 +326,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<code>set room=kitchen:FILTER=STATE!=off off</code><br>
|
||||
<code>list disabled=</code><br>
|
||||
<code>list TYPE=FS20 STATE</code><br>
|
||||
<code>list i:TYPE=FS20 STATE</code><br>
|
||||
</ul>
|
||||
Notes:
|
||||
<ul>
|
||||
|
@ -319,7 +319,10 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
<li>ein regulärer Ausdruck</li>
|
||||
<li>ein NAME=WERT Ausdruck, wo NAME ein "Internal" Wert wie TYPE ist, ein
|
||||
Reading-Name oder ein Attribut. WERT ist ein regulärer Ausdruck.
|
||||
Um die Bedingung zu negieren, sollte NAME!=WERT verwendet werden.
|
||||
Um die Bedingung zu negieren, muss NAME!=WERT verwendet werden.
|
||||
Um die Suche einzugrenzen, kann man als Praefix i: für internal
|
||||
Werte, r: für Reading-Namen und a: für Attribute verwenden,
|
||||
siehe das Beispiel unten.
|
||||
</li>
|
||||
<li>Falls die Spezifikation von :FILTER=NAME=WERT gefolgt wird,
|
||||
dann wird die zuvor gefundene Liste durch diesen neuen Ausdruck
|
||||
@ -335,6 +338,7 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
<code>set room=kitchen:FILTER=STATE!=off off</code><br>
|
||||
<code>list disabled=</code><br>
|
||||
<code>list TYPE=FS20 STATE</code><br>
|
||||
<code>list i:TYPE=FS20 STATE</code><br>
|
||||
</ul>
|
||||
Bemerkungen:
|
||||
<ul>
|
||||
|
12
fhem/fhem.pl
12
fhem/fhem.pl
@ -1092,6 +1092,11 @@ devspec2array($;$)
|
||||
}
|
||||
($n,$op,$re) = ($1,"eval","") if($dName =~ m/^{(.*)}$/);
|
||||
|
||||
my $fType="";
|
||||
if($n =~ m/^(.:)(.*$)/) {
|
||||
$fType = $1;
|
||||
$n = $2;
|
||||
}
|
||||
@res=();
|
||||
foreach my $d (@names) {
|
||||
next if($attr{$d} && $attr{$d}{ignore});
|
||||
@ -1107,12 +1112,13 @@ devspec2array($;$)
|
||||
Log 1, "Error: $d has no TYPE";
|
||||
next;
|
||||
}
|
||||
my $val = $hash->{$n};
|
||||
if(!defined($val)) {
|
||||
my $val;
|
||||
$val = $hash->{$n} if(!$fType || $fType eq "i:");
|
||||
if(!defined($val) && (!$fType || $fType eq "r:")) {
|
||||
my $r = $hash->{READINGS};
|
||||
$val = $r->{$n}{VAL} if($r && $r->{$n});
|
||||
}
|
||||
if(!defined($val)) {
|
||||
if(!defined($val) && (!$fType || $fType eq "a:")) {
|
||||
$val = $attr{$d}{$n} if($attr{$d});
|
||||
}
|
||||
$val="" if(!defined($val));
|
||||
|
Loading…
Reference in New Issue
Block a user