From 0d75b6b4e37972abf017f0d1a58c07ae462b691c Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Fri, 9 Jan 2015 11:56:01 +0000 Subject: [PATCH] 33_readingsGroup.pm: allow devspec :FILTER= expressions in device selection git-svn-id: https://svn.fhem.de/fhem/trunk@7478 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/33_readingsGroup.pm | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 2438fecb5..968e1cddb 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: readingsGroup: allow devspec :FILTER= expressions in device selection - added: 73_km200.pm for the Buderus KM200 heating controller (Sailor) - feature: 70_XBMC: added command 'connect' to connect instantly - change: FB_CALLMONITOR: use standard file read/write function to support use of configDb diff --git a/fhem/FHEM/33_readingsGroup.pm b/fhem/FHEM/33_readingsGroup.pm index 1d61d7a42..9c3f6621b 100644 --- a/fhem/FHEM/33_readingsGroup.pm +++ b/fhem/FHEM/33_readingsGroup.pm @@ -96,7 +96,19 @@ readingsGroup_updateDevices($;$) } else { my @device = split(":", $param); - if($device[0] =~ m/(.*)=(.*)/) { + if( $device[1] =~ m/^FILTER=/ ) { + my $devspec = shift(@device); + while( @device && $device[0] =~ m/^FILTER=/ ) { + $devspec .= ":"; + $devspec .= shift(@device) + } + my $regex = $device[0]; + foreach my $d (devspec2array($devspec)) { + $list{$d} = 1; + push @devices, [$d,$regex]; + } + + } elsif($device[0] =~ m/(.*)=(.*)/) { my ($lattr,$re) = ($1, $2); foreach my $d (sort keys %defs) { next if( IsIgnored($d) ); @@ -105,6 +117,7 @@ readingsGroup_updateDevices($;$) $list{$d} = 1; push @devices, [$d,$device[1]]; } + } elsif($device[0] =~ m/(.*)&(.*)/) { my ($lattr,$re) = ($1, $2); foreach my $d (sort keys %attr) { @@ -114,11 +127,14 @@ readingsGroup_updateDevices($;$) $list{$d} = 1; push @devices, [$d,$device[1]]; } + } elsif($device[0] =~ m/^<.*>$/) { push @devices, [$device[0]]; + } elsif( defined($defs{$device[0]}) ) { $list{$device[0]} = 1; push @devices, [@device]; + } else { foreach my $d (sort keys %defs) { next if( IsIgnored($d) ); @@ -966,7 +982,7 @@ readingsGroup_Notify($$) || ($regex =~ m/@\{/ && $regex !~ m/}$/) ) #handle , in reading@{...} && defined($list[++$i]) ) { $regex .= ",". $list[$i]; - } + } next if( $reading eq "state" && !$show_state && (!defined($regex) || $regex ne "state") ); my $modifier = ""; if( $regex && $regex =~ m/^([+?!]*)(.*)/ ) { @@ -1217,6 +1233,7 @@ readingsGroup_Attr($$$;$)
  • <device> can be of the form ATTRIBUTE&VALUE where ATTRIBUTE is the name of an attribute and VALUE is a regex.
  • <device> can be of the form <STRING> or <{perl}> where STRING or the string returned by perl is inserted as a line in the readings list. skipped if STRING is undef.
  • +
  • <device> can be a devspec (see devspec) with at least one FILTER expression.
  • If regex is a comma separatet list the reading values will be shown on a single line.
  • If regex starts with a '+' it will be matched against the internal values of the device instead of the readings.
  • If regex starts with a '?' it will be matched against the attributes of the device instead of the readings.