From 999af8391572cc91aaf3208ecbdfd26fe59f2daa Mon Sep 17 00:00:00 2001 From: hexenmeister Date: Fri, 28 Jun 2019 15:56:35 +0000 Subject: [PATCH] fixed: globalPublish git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@19737 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/10_MQTT_GENERIC_BRIDGE.pm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/FHEM/10_MQTT_GENERIC_BRIDGE.pm b/FHEM/10_MQTT_GENERIC_BRIDGE.pm index 087eb97d4..c935fee1c 100644 --- a/FHEM/10_MQTT_GENERIC_BRIDGE.pm +++ b/FHEM/10_MQTT_GENERIC_BRIDGE.pm @@ -30,6 +30,9 @@ # # CHANGE LOG # +# 25.06.2019 1.2.6 +# bugfix : globalPublish ohne funktion +# # 06.06.2019 1.2.5 # bugfix : Korrekte Trennung von Events mit mehrzeiligen Werten # (regex Schalter /sm) @@ -360,7 +363,7 @@ use warnings; #my $DEBUG = 1; my $cvsid = '$Id$'; -my $VERSION = "version 1.2.5 by hexenmeister\n$cvsid"; +my $VERSION = "version 1.2.6 by hexenmeister\n$cvsid"; my %sets = ( ); @@ -1088,7 +1091,10 @@ sub getDevicePublishRec($$$) { my $globalMap = $map->{':global'}; my $devMap = $map->{$dev}; + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> devmap: ".Dumper($devMap)); + foreach my $key (keys %{$devMap->{':publish'}} ) { + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> dev: $key"); my($keyRName,$keyPostfix) = split("!",$key); if($keyRName eq $reading) { my $devRec = getDevicePublishRecIntern($hash, $devMap, $globalMap, $dev, $key, $reading, $keyPostfix); @@ -1100,6 +1106,7 @@ sub getDevicePublishRec($$$) { if(!@$ret) { #push(@$ret, getDevicePublishRecIntern($hash, $devMap, $globalMap, $dev, $reading, $reading, undef)); foreach my $key (keys %{$devMap->{':publish'}} ) { + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> dev: $key"); my($keyRName,$keyPostfix) = split("!",$key); if($keyRName eq '*') { my $devRec = getDevicePublishRecIntern($hash, $devMap, $globalMap, $dev, $key, $reading, $keyPostfix); @@ -1109,6 +1116,13 @@ sub getDevicePublishRec($$$) { } } + # wenn immer noch keine explizite Readings gefunden wurden, dann noch einmal in globalPublishMap suchen + if(!@$ret) { + my $devRec = getDevicePublishRecIntern($hash, $devMap, $globalMap, $dev, $reading, $reading, ''); + #$devRec->{'postfix'}=defined($keyPostfix)?$keyPostfix:''; + push(@$ret, $devRec) if defined $devRec; + } + return $ret; } @@ -1145,8 +1159,8 @@ sub getDevicePublishRecIntern($$$$$$$) { #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> readingMap ".Dumper($readingMap)); #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> wildcardReadingMap ".Dumper($wildcardReadingMap)); - #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> readingMap ".Dumper($globalReadingMap)); - #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> wildcardReadingMap ".Dumper($globalWildcardReadingsMap)); + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> global readingMap ".Dumper($globalReadingMap)); + #Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE:DEBUG:> [$hash->{NAME}] getDevicePublishRec> global wildcardReadingMap ".Dumper($globalWildcardReadingsMap)); # topic my $topic = undef; $topic = $readingMap->{'topic'} if defined $readingMap;