From 7e02c85b40d49a0035399975726b9eb08c23a485 Mon Sep 17 00:00:00 2001 From: hexenmeister Date: Mon, 19 Nov 2018 19:51:07 +0000 Subject: [PATCH] bugfix: fix update multiple readings for the same topic git-svn-id: https://svn.fhem.de/fhem/trunk@17786 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm b/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm index c6b25a806..bac5aab8c 100644 --- a/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm +++ b/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm @@ -30,6 +30,9 @@ # # CHANGE LOG # +# 19.11.2018 1.0.1 +# bugfix : fix update multiple readings for the same topic +# # 17.11.2018 1.0.0 # change : IOWrite Parameter angepasst. # @@ -240,7 +243,7 @@ use warnings; #my $DEBUG = 1; my $cvsid = '$Id$'; -my $VERSION = "version 1.0.0 by hexenmeister\n$cvsid"; +my $VERSION = "version 1.0.1 by hexenmeister\n$cvsid"; my %sets = ( ); @@ -2352,7 +2355,7 @@ sub doSetUpdate($$$$$) { my $dhash = $defs{$device}; return unless defined $dhash; - + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE: setUpdate enter: update: $reading = $message"); my $doForward = isDoForward($hash, $device,$reading); if($mode eq 'S') { @@ -2384,6 +2387,7 @@ sub doSetUpdate($$$$$) { } readingsBulkUpdate($dhash,$reading,$message); readingsEndUpdate($dhash,1); + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE: setUpdate: update: $reading = $message"); # wird in 'notify' entfernt # delete $dhash->{'.mqttGenericBridge_triggeredReading'}; $hash->{+HELPER}->{+HS_PROP_NAME_UPDATE_R_CNT}++; @@ -2436,6 +2440,8 @@ sub onmessage($$$) { my $fMap = searchDeviceForTopic($hash, $topic); #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> onmessage: $fMap : ".Dumper($fMap)); + my $updated = 0; + my @updatedList; foreach my $deviceKey (keys %{$fMap}) { my $device = $fMap->{$deviceKey}->{'device'}; my $reading = $fMap->{$deviceKey}->{'reading'}; @@ -2485,8 +2491,6 @@ sub onmessage($$$) { next unless defined $message; - my $updated = 0; - my @updatedList; if(defined($redefMap)) { foreach my $key (keys %{$redefMap}) { my $val = $redefMap->{$key}; @@ -2508,11 +2512,9 @@ sub onmessage($$$) { #if($updated) { #updateSubTime($device,$reading); #} - - return @updatedList if($updated); - return undef; } - + return @updatedList if($updated); + return undef; } 1;