From cb679fb1a86cdf25ab47a558dc34fed2d14b5d97 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 5 Feb 2016 10:36:50 +0000 Subject: [PATCH] 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 --- fhem/FHEM/01_FHEMWEB.pm | 6 ++++++ fhem/fhem.pl | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 1af2ce451..83006ac11 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -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}; diff --git a/fhem/fhem.pl b/fhem/fhem.pl index c85f705ad..ffe19622f 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -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}); } }