From 7de9015eea7f65a1c3c4f23e09f8a8cfad8e5704 Mon Sep 17 00:00:00 2001 From: joachim09876 <> Date: Mon, 12 May 2014 13:13:22 +0000 Subject: [PATCH] 98_cloneDummy: Erweiterung zum Filtern doppelter Readings git-svn-id: https://svn.fhem.de/fhem/trunk@5825 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_cloneDummy.pm | 44 +++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/fhem/FHEM/98_cloneDummy.pm b/fhem/FHEM/98_cloneDummy.pm index 77b5e911e..ace6eeaa4 100644 --- a/fhem/FHEM/98_cloneDummy.pm +++ b/fhem/FHEM/98_cloneDummy.pm @@ -57,16 +57,32 @@ sub cloneDummy_Notify($$) { $rname = substr($rname,0,length($rname)-1); my %check = map { $_ => 1 } split(/,/,AttrVal($hn,'cloneIgnore','')); - readingsBeginUpdate($hash); + # When more than one FHEM2FHEM instance is used to tap into RF traffic, + # we may get duplicate readings for the same sensor information. + # Use CheckDuplicate to prevent multiple events in this case. + # + # Currently, clonedummy accepts a device name rather than a REGEXP, so + # we can assume that all duplicates will have the same device name + # (rather than different IODEV names as is the case with other modules) + # - so we ned to leave empty the first parameter for CheckDuplicate() + # + # If cloneDummy should be changed to accepting more than one device, we + # will may want to adapt the call to CheckDuplicate. + my ($isdup, $idx) = CheckDuplicate("", "$hn: $reading", undef); + if ($isdup) { + Log3 $hash, 4, "cloneDummy: drop duplicate <$dn> <$hn> <$reading> ***"; + } else { + Log3 $hash, 4, "cloneDummy: publish unique <$dn> <$hn> <$reading>"; + readingsBeginUpdate($hash); if (($hs ne "") && ($rname eq $hs) ){ - readingsBulkUpdate($hash,"_state", $reading); + readingsBulkUpdate($hash,"_state", $reading); + } + readingsBulkUpdate($hash,"state", "active"); + unless (exists ($check{$rname})) { + readingsBulkUpdate($hash, $rname, $rval); + } + readingsEndUpdate($hash, 1); } - readingsBulkUpdate($hash,"state", "active"); - unless (exists ($check{$rname})) { - readingsBulkUpdate($hash, $rname, $rval); - } - readingsEndUpdate($hash, 1); - return; } @@ -79,7 +95,11 @@ sub cloneDummy_Notify($$) {