2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

bugfix: mqttDefauts has no effect for qos/retain

git-svn-id: https://svn.fhem.de/fhem/trunk@17564 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
hexenmeister 2018-10-18 20:28:34 +00:00
parent 2a591a8abe
commit b7b44b5f7f

View File

@ -29,12 +29,16 @@
############################################################################### ###############################################################################
# #
# CHANGE LOG # CHANGE LOG
#
# 18.10.2018 0.9.9
# bugfix : qos/retain/expression aus 'mqttDefaults' in Device wurden nicht
# verwendet (Fehler bei der Suche (Namen))
# #
# 14.10.2018 0.9.9 # 14.10.2018 0.9.9
# change : 'mqttForward' dokumentiert # change : 'mqttForward' dokumentiert
# improved : Laden von MQTT-Modul in BEGIN-Block verlagert. # improved : Laden von MQTT-Modul in BEGIN-Block verlagert.
# Es gab Meldungen ueber Probleme (undefined subroutine) wenn # Es gab Meldungen ueber Probleme (undefined subroutine) wenn
# MQTT-Modul in fhem.cfg nach dem Bridge-Modul stand. # MQTT-Modul in fhem.cfg nach dem Bridge-Modul stand.
# #
# 11.10.2018 0.9.9 # 11.10.2018 0.9.9
# change : 'self-trigger-topic' wieder ausgebaut. # change : 'self-trigger-topic' wieder ausgebaut.
@ -190,6 +194,7 @@
# - Variablen in Expression funktionieren nicht, wenn Topic kein perl-Expression ist # - Variablen in Expression funktionieren nicht, wenn Topic kein perl-Expression ist
# - atopic wird in devInfo nicht dargestellt # - atopic wird in devInfo nicht dargestellt
# - beim Aendern von mqttXXX und globalXXX mit Zeilenumbruechen werden interne Tabellen nicht aktualisiert # - beim Aendern von mqttXXX und globalXXX mit Zeilenumbruechen werden interne Tabellen nicht aktualisiert
# - qos/retain ueber mqttDefaults funktionieren nicht (in publish als *:retaind=1 dagegen schon)
# #
# [testing] # [testing]
# #
@ -883,7 +888,8 @@ sub getDevicePublishRecIntern($$$$$) {
# reading map # reading map
my $readingMap = $publishMap->{$reading} if defined $publishMap; my $readingMap = $publishMap->{$reading} if defined $publishMap;
my $defaultReadingMap = $publishMap->{'*'} if defined $publishMap; #my $defaultReadingMap = $publishMap->{'*'} if defined $publishMap;
my $defaultReadingMap = $devMap->{':defaults'} if defined $publishMap;
# global reading map # global reading map
my $globalReadingMap = $globalPublishMap->{$reading} if defined $globalPublishMap; my $globalReadingMap = $globalPublishMap->{$reading} if defined $globalPublishMap;
@ -960,48 +966,59 @@ sub retrieveQosRetainExpression($$$$) {
my $retain = undef; my $retain = undef;
my $expression = undef; my $expression = undef;
# Log3('GB',1,"MQTT_GENERIC_BRIDGE: retrieveQosRetainExpression: globalDefaultReadingMap: ".Dumper($globalDefaultReadingMap));
# Log3('GB',1,"MQTT_GENERIC_BRIDGE: retrieveQosRetainExpression: globalReadingMap: ".Dumper($globalReadingMap));
# Log3('GB',1,"MQTT_GENERIC_BRIDGE: retrieveQosRetainExpression: defaultReadingMap: ".Dumper($defaultReadingMap));
# Log3('GB',1,"MQTT_GENERIC_BRIDGE: retrieveQosRetainExpression: readingMap: ".Dumper($readingMap));
if(defined $readingMap) { if(defined $readingMap) {
$qos = $readingMap->{'qos'}; $qos = $readingMap->{'qos'};
$retain = $readingMap->{'retain'}; $retain = $readingMap->{'retain'};
$expression = $readingMap->{'expression'}; $expression = $readingMap->{'expression'};
if(defined($readingMap->{':defaults'})) { # if(defined($readingMap->{':defaults'})) {
$qos = $readingMap->{':defaults'}->{'pub:qos'} unless defined $qos; # $qos = $readingMap->{':defaults'}->{'pub:qos'} unless defined $qos;
$retain = $readingMap->{':defaults'}->{'pub:retain'} unless defined $retain; # $retain = $readingMap->{':defaults'}->{'pub:retain'} unless defined $retain;
$expression = $readingMap->{':defaults'}->{'expression'} unless defined $expression; # $expression = $readingMap->{':defaults'}->{'expression'} unless defined $expression;
} # }
} }
if(defined $defaultReadingMap) { if(defined $defaultReadingMap) {
$qos = $defaultReadingMap->{'pub:qos'} unless defined $qos;
$retain = $defaultReadingMap->{'pub:retain'} unless defined $retain;
$expression = $defaultReadingMap->{'pub:expression'} unless defined $expression;
$qos = $defaultReadingMap->{'qos'} unless defined $qos; $qos = $defaultReadingMap->{'qos'} unless defined $qos;
$retain = $defaultReadingMap->{'retain'} unless defined $retain; $retain = $defaultReadingMap->{'retain'} unless defined $retain;
$expression = $defaultReadingMap->{'expression'} unless defined $expression; $expression = $defaultReadingMap->{'expression'} unless defined $expression;
if(defined($defaultReadingMap->{':defaults'})) { # if(defined($defaultReadingMap->{':defaults'})) {
$qos = $defaultReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos; # $qos = $defaultReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos;
$retain = $defaultReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain; # $retain = $defaultReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain;
$expression = $defaultReadingMap->{':defaults'}->{'expression'} unless defined $expression; # $expression = $defaultReadingMap->{':defaults'}->{'expression'} unless defined $expression;
} # }
} }
if(defined $globalReadingMap) { if(defined $globalReadingMap) {
$qos = $globalReadingMap->{'qos'}; $qos = $globalReadingMap->{'qos'};
$retain = $globalReadingMap->{'retain'}; $retain = $globalReadingMap->{'retain'};
$expression = $globalReadingMap->{'expression'} unless defined $expression; $expression = $globalReadingMap->{'expression'} unless defined $expression;
if(defined($globalReadingMap->{':defaults'})) { # if(defined($globalReadingMap->{':defaults'})) {
$qos = $globalReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos; # $qos = $globalReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos;
$retain = $globalReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain; # $retain = $globalReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain;
$expression = $globalReadingMap->{':defaults'}->{'expression'} unless defined $expression; # $expression = $globalReadingMap->{':defaults'}->{'expression'} unless defined $expression;
} # }
} }
if(defined $globalDefaultReadingMap) { if(defined $globalDefaultReadingMap) {
$qos = $globalDefaultReadingMap->{'pub:qos'} unless defined $qos;
$retain = $globalDefaultReadingMap->{'pub:retain'} unless defined $retain;
$expression = $globalDefaultReadingMap->{'pub:expression'} unless defined $expression;
$qos = $globalDefaultReadingMap->{'qos'} unless defined $qos; $qos = $globalDefaultReadingMap->{'qos'} unless defined $qos;
$retain = $globalDefaultReadingMap->{'retain'} unless defined $retain; $retain = $globalDefaultReadingMap->{'retain'} unless defined $retain;
$expression = $globalDefaultReadingMap->{'expression'} unless defined $expression; $expression = $globalDefaultReadingMap->{'expression'} unless defined $expression;
if(defined($globalDefaultReadingMap->{':defaults'})) { # if(defined($globalDefaultReadingMap->{':defaults'})) {
$qos = $globalDefaultReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos; # $qos = $globalDefaultReadingMap->{':defaults'}->{'pub:qos'} unless defined $qos;
$retain = $globalDefaultReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain; # $retain = $globalDefaultReadingMap->{':defaults'}->{'pub:retain'} unless defined $retain;
$expression = $globalDefaultReadingMap->{':defaults'}->{'expression'} unless defined $expression; # $expression = $globalDefaultReadingMap->{':defaults'}->{'expression'} unless defined $expression;
} # }
} }
$qos = 0 unless defined $qos; $qos = 0 unless defined $qos;