From 4ac8c67ae2542e0737ecadbd62ff6ac46de31b6e Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Mon, 26 Jan 2015 15:52:49 +0000 Subject: [PATCH] 33_readingsGroup.pm: use deviceEvents() git-svn-id: https://svn.fhem.de/fhem/trunk@7735 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/33_readingsGroup.pm | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/fhem/FHEM/33_readingsGroup.pm b/fhem/FHEM/33_readingsGroup.pm index 114f80035..078d47c61 100644 --- a/fhem/FHEM/33_readingsGroup.pm +++ b/fhem/FHEM/33_readingsGroup.pm @@ -881,11 +881,14 @@ readingsGroup_Notify($$) my ($hash,$dev) = @_; my $name = $hash->{NAME}; - if( grep(m/^INITIALIZED$/, @{$dev->{CHANGED}}) ) { + my $events = deviceEvents($dev,1); + return if( !$events ); + + if( grep(m/^INITIALIZED$/, @{$events}) ) { readingsGroup_updateDevices($hash); return undef; } - elsif( grep(m/^REREADCFG$/, @{$dev->{CHANGED}}) ) { + elsif( grep(m/^REREADCFG$/, @{$events}) ) { readingsGroup_updateDevices($hash); return undef; } @@ -898,9 +901,9 @@ readingsGroup_Notify($$) my $devices = $hash->{DEVICES}; $devices = $hash->{DEVICES2} if( $hash->{DEVICES2} ); - my $max = int(@{$dev->{CHANGED}}); + my $max = int(@{$events}); for (my $i = 0; $i < $max; $i++) { - my $s = $dev->{CHANGED}[$i]; + my $s = $events->[$i]; $s = "" if(!defined($s)); if( $dev->{NAME} eq "global" && $s =~ m/^RENAMED ([^ ]*) ([^ ]*)$/) { @@ -940,21 +943,12 @@ readingsGroup_Notify($$) } } - my @parts = split(/: /,$s); - my $reading = shift @parts; - my $value = join(": ", @parts); - - $reading = "" if( !defined($reading) ); + my ($reading,$value) = split(": ",$events->[$i],2); + next if( !defined($value) ); next if( $reading =~ m/^\./); + $reading = "" if( !defined($reading) ); $value = "" if( !defined($value) ); - my $show_state = 1; - if( $value eq "" ) { - $show_state = !AttrVal( $name, "nostate", "0" ); - #next if( !$show_state ); - - $reading = "state"; - $value = $s; - } + my $show_state = !AttrVal( $name, "nostate", "0" ); foreach my $device (@{$devices}) { my $item = 0;