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($$) {

cloneDummy