diff --git a/fhem/CHANGED b/fhem/CHANGED index 292241967..3c207a007 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. - SVN + - feature: devspec: removed range, added :FILTER and more general search - feature: HUEBridge,HUEDevice: support for groups added - feature: YAMAHA_AVR: new argument "toggle" for mute command - feature: FB_CALLMONITOR: replace & to & at reverse search diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index e2239f1dd..796b4b341 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -279,34 +279,33 @@ A line ending with \ will be concatenated with the next one, so long lines - Example: + Examples: Notes: diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index d61c4aa33..4b202cc53 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -265,56 +265,59 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.

Geräte-Spezifikation (devspec)

diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 77950f34a..da0f7142c 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -862,8 +862,6 @@ AnalyzeCommand($$) sub devspec2array($) { - my %knownattr = ( "DEF"=>1, "STATE"=>1, "TYPE"=>1 ); - my ($name) = @_; return "" if(!defined($name)); @@ -872,59 +870,44 @@ devspec2array($) return "FHEM2FHEM_FAKE_$name" if($defs{$name}{FAKEDEVICE}); return $name; } - # FAKE is set by FHEM2FHEM LOG - my ($isattr, @ret); + my @ret; + foreach my $l (split(",", $name)) { # List of elements + my @names = sort keys %defs; + my @res; + foreach my $dName (split(":FILTER=", $name)) { + my ($n,$op,$re) = ("NAME","=",$dName); + ($n,$op,$re) = ($1,$2,$3) if($dName =~ m/^([^!]*)(=|!=)(.*)$/); - foreach my $l (split(",", $name)) { # List - - if($l =~ m/(.*)=(.*)/) { - my ($lattr,$re) = ($1, $2); - if($knownattr{$lattr}) { - eval { # a bad regexp may shut down fhem.pl - foreach my $l (sort keys %defs) { - push @ret, $l - if($defs{$l}{$lattr} && (!$re || $defs{$l}{$lattr}=~m/^$re$/)); + @res=(); + foreach my $d (@names) { + next if($attr{$d} && $attr{$d}{ignore}); + my $hash = $defs{$d}; + my $val = $hash->{$n}; + if(!defined($val)) { + my $r = $hash->{READINGS}; + $val = $r->{$n}{VAL} if($r && $r->{$n}); + } + if(!defined($val)) { + $val = $attr{$d}{$n} if($attr{$d}); + } + next if(!defined($val)); + eval { # a bad regexp is deadly + if(($op eq "=" && $val =~ m/^$re$/) || + ($op eq "!=" && $val !~ m/^$re$/)) { + push @res, $d } }; if($@) { Log 1, "devspec2array $name: $@"; return $name; } - } else { - foreach my $l (sort keys %attr) { - push @ret, $l - if($attr{$l}{$lattr} && (!$re || $attr{$l}{$lattr} =~ m/$re/)); - } } - $isattr = 1; - next; + @names = @res; } - - my $regok; - eval { # a bad regexp may shut down fhem.pl - if($l =~ m/[*\[\]^\$]/) { # Regexp - push @ret, grep($_ =~ m/^$l$/, sort keys %defs); - $regok = 1; - } - }; - if($@) { - Log 1, "devspec2array $name: $@"; - return $name; - } - next if($regok); - - if($l =~ m/-/) { # Range - my ($lower, $upper) = split("-", $l, 2); - push @ret, grep($_ ge $lower && $_ le $upper, sort keys %defs); - next; - } - push @ret, $l; + push @ret,@res; } - - return $name if(!@ret && !$isattr); # No match, return the input - @ret = grep { !$attr{$_} || !$attr{$_}{ignore} } @ret - if($name !~ m/^ignore=/); + return $name if(!@ret); return @ret; }