mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-13 09:12:19 +00:00
AttrTemplate.pm: More complex filtering (Forum #97989)
git-svn-id: https://svn.fhem.de/fhem/trunk@18845 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5c00061f1e
commit
21394f215f
@ -43,9 +43,8 @@ AttrTemplate_Initialize()
|
||||
$templates{$name}{desc} = $lastComment if($lastComment);
|
||||
$lastComment = "";
|
||||
|
||||
} elsif($line =~ m/^filter:(.*)=(.*)/) {
|
||||
$templates{$name}{filterName} = $1;
|
||||
$templates{$name}{filterVal} = $2;
|
||||
} elsif($line =~ m/^filter:(.*)/) {
|
||||
$templates{$name}{filter} = $1;
|
||||
|
||||
} elsif($line =~ m/^par:(.*)/) {
|
||||
push(@{$templates{$name}{pars}}, $1);
|
||||
@ -78,7 +77,8 @@ AttrTemplate_Set($$@)
|
||||
my @list;
|
||||
for my $k (sort keys %templates) {
|
||||
my $h = $templates{$k};
|
||||
if(!$h->{filterName} || $hash->{$h->{filterName}} eq $h->{filterVal}) {
|
||||
my $matches = grep /$name/, devspec2array($h->{filter}) if($h->{filter});
|
||||
if(!$h->{filter} || $matches) {
|
||||
push @list, $k;
|
||||
$haveDesc = 1 if($h->{desc});
|
||||
}
|
||||
@ -97,7 +97,8 @@ AttrTemplate_Set($$@)
|
||||
my @hlp;
|
||||
for my $k (sort keys %templates) {
|
||||
my $h = $templates{$k};
|
||||
if(!$h->{filterName} || $hash->{$h->{filterName}} eq $h->{filterVal}) {
|
||||
my $matches = grep /$name/, devspec2array($h->{filter}) if($h->{filter});
|
||||
if(!$h->{filter} || $matches) {
|
||||
push @hlp, "$k: $h->{desc}" if($h->{desc});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user