mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
fhem.pl: add i:/r:/a: to devspec (Forum #45801)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@10208 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c5b4d491f3
commit
cf91df8f99
@ -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 single device name. This is the most common case.</li>
|
||||||
<li>a list of devices, separated by comma (,)</li>
|
<li>a list of devices, separated by comma (,)</li>
|
||||||
<li>a regular expression</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
|
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
|
<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.
|
values found in the first round are filtered by the second expression.
|
||||||
</ul>
|
</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>set room=kitchen:FILTER=STATE!=off off</code><br>
|
||||||
<code>list disabled=</code><br>
|
<code>list disabled=</code><br>
|
||||||
<code>list TYPE=FS20 STATE</code><br>
|
<code>list TYPE=FS20 STATE</code><br>
|
||||||
|
<code>list i:TYPE=FS20 STATE</code><br>
|
||||||
</ul>
|
</ul>
|
||||||
Notes:
|
Notes:
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -319,7 +319,10 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
|||||||
<li>ein regulärer Ausdruck</li>
|
<li>ein regulärer Ausdruck</li>
|
||||||
<li>ein NAME=WERT Ausdruck, wo NAME ein "Internal" Wert wie TYPE ist, ein
|
<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.
|
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>
|
||||||
<li>Falls die Spezifikation von :FILTER=NAME=WERT gefolgt wird,
|
<li>Falls die Spezifikation von :FILTER=NAME=WERT gefolgt wird,
|
||||||
dann wird die zuvor gefundene Liste durch diesen neuen Ausdruck
|
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>set room=kitchen:FILTER=STATE!=off off</code><br>
|
||||||
<code>list disabled=</code><br>
|
<code>list disabled=</code><br>
|
||||||
<code>list TYPE=FS20 STATE</code><br>
|
<code>list TYPE=FS20 STATE</code><br>
|
||||||
|
<code>list i:TYPE=FS20 STATE</code><br>
|
||||||
</ul>
|
</ul>
|
||||||
Bemerkungen:
|
Bemerkungen:
|
||||||
<ul>
|
<ul>
|
||||||
|
12
fhem.pl
12
fhem.pl
@ -1092,6 +1092,11 @@ devspec2array($;$)
|
|||||||
}
|
}
|
||||||
($n,$op,$re) = ($1,"eval","") if($dName =~ m/^{(.*)}$/);
|
($n,$op,$re) = ($1,"eval","") if($dName =~ m/^{(.*)}$/);
|
||||||
|
|
||||||
|
my $fType="";
|
||||||
|
if($n =~ m/^(.:)(.*$)/) {
|
||||||
|
$fType = $1;
|
||||||
|
$n = $2;
|
||||||
|
}
|
||||||
@res=();
|
@res=();
|
||||||
foreach my $d (@names) {
|
foreach my $d (@names) {
|
||||||
next if($attr{$d} && $attr{$d}{ignore});
|
next if($attr{$d} && $attr{$d}{ignore});
|
||||||
@ -1107,12 +1112,13 @@ devspec2array($;$)
|
|||||||
Log 1, "Error: $d has no TYPE";
|
Log 1, "Error: $d has no TYPE";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my $val = $hash->{$n};
|
my $val;
|
||||||
if(!defined($val)) {
|
$val = $hash->{$n} if(!$fType || $fType eq "i:");
|
||||||
|
if(!defined($val) && (!$fType || $fType eq "r:")) {
|
||||||
my $r = $hash->{READINGS};
|
my $r = $hash->{READINGS};
|
||||||
$val = $r->{$n}{VAL} if($r && $r->{$n});
|
$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 = $attr{$d}{$n} if($attr{$d});
|
||||||
}
|
}
|
||||||
$val="" if(!defined($val));
|
$val="" if(!defined($val));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user