2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

01_FHEMWEB.pm: Add FILTER= to FW_directNotify (Forum #48736)

git-svn-id: https://svn.fhem.de/fhem/trunk@10727 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-02-05 10:36:50 +00:00
parent 2125ac1077
commit cb679fb1a8
2 changed files with 15 additions and 5 deletions

View File

@ -2606,6 +2606,11 @@ FW_Notify($$)
sub
FW_directNotify($@) # Notify without the event overhead (Forum #31293)
{
my $filter;
if($_[0] =~ m/^FILTER=(.*)/) {
$filter = "^$1\$";
shift;
}
my $dev = $_[0];
foreach my $ntfy (values(%defs)) {
next if(!$ntfy->{TYPE} ||
@ -2613,6 +2618,7 @@ FW_directNotify($@) # Notify without the event overhead (Forum #31293)
!$ntfy->{inform} ||
!$ntfy->{inform}{devices}{$dev} ||
$ntfy->{inform}{type} ne "status");
next if($filter && $ntfy->{inform}{filter} !~ m/$filter/);
if(!addToWritebuffer($ntfy,
FW_longpollInfo($ntfy->{inform}{fmt}, @_)."\n")) {
my $name = $ntfy->{NAME};

View File

@ -2144,9 +2144,12 @@ CommandList($$)
if($defs{$sdev}) {
if(defined($defs{$sdev}{$n}) && (!$fType || $fType eq "i:")) {
my $val = $defs{$sdev}{$n};
$val = $val->{NAME} if(ref($val) eq 'HASH' && $val->{NAME});
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'', $arg[2]?19:0, '',
$arg[2]?-15:0, $arg[2]?$n:'', $val);
if(ref($val) eq 'HASH') {
$val = ($val->{NAME} ? $val->{NAME} : # ???
join(" ", map { "$_=$val->{$_}" } sort keys %{$val}));
}
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'',
$arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'', $val);
} elsif($defs{$sdev}{READINGS} &&
defined($defs{$sdev}{READINGS}{$n})
@ -2159,8 +2162,9 @@ CommandList($$)
} elsif($attr{$sdev} &&
defined($attr{$sdev}{$n})
&& (!$fType || $fType eq "a:")) {
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'', $arg[2]?19:0, '',
$arg[2]?-15:0, $arg[2]?$n:'', $attr{$sdev}{$n});
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'',
$arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'',
$attr{$sdev}{$n});
}
}