diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm
index 9a284f273..9c503ca39 100644
--- a/fhem/FHEM/00_MQTT2_CLIENT.pm
+++ b/fhem/FHEM/00_MQTT2_CLIENT.pm
@@ -56,6 +56,7 @@ MQTT2_CLIENT_Initialize($)
subscriptions
SSL
sslargs
+ topicConversion:0,1
username
);
use warnings 'qw';
@@ -517,7 +518,7 @@ MQTT2_CLIENT_Read($@)
}
$val = substr($pl, $off);
if($unicodeEncoding) {
- if(!$hash->{binaryTopicRegexp} || $tp !~ m/^$hash->{binaryTopicRegexp}$/) {
+ if(!$hash->{binaryTopicRegexp} || $tp !~ m/^$hash->{binaryTopicRegexp}$/){
$val = Encode::decode('UTF-8', $val);
}
}
@@ -530,10 +531,10 @@ MQTT2_CLIENT_Read($@)
my $ir = AttrVal($name, "ignoreRegexp", undef);
if(!defined($ir) || "$tp:$val" !~ m/$ir/) {
my $ac = AttrVal($name, "autocreate", "no");
- $ac = $ac eq "1" ? "simple" : ($ac eq "0" ? "no" : $ac); # backward comp.
+ $ac = $ac eq "1" ? "simple" : ($ac eq "0" ? "no" : $ac); #backward comp.
my $cid = makeDeviceName($hash->{clientId});
- $tp =~ s/:/_/g; # 96608
+ $tp =~ s/:/_/g if(AttrVal($name, "topicConversion", 1)); # 96608
Dispatch($hash, "autocreate=$ac\0$cid\0$tp\0$val", undef, $ac eq "no");
my $re = AttrVal($name, "rawEvents", undef);
@@ -942,6 +943,13 @@ MQTT2_CLIENT_feedTheList($$$)
possible options documented in perldoc IO::Socket::SSL
+
+
topicConversion [1|0]
+ due to historic reasons colon (:) is converted in the topic to underscore
+ (_). Setting this attribute to 0 will disable this conversion. Default
+ is 1.
+
+
username <username>
set the username. The password is set via the set command, and is stored
diff --git a/fhem/FHEM/00_MQTT2_SERVER.pm b/fhem/FHEM/00_MQTT2_SERVER.pm
index 91ce71756..bd15fcc03 100644
--- a/fhem/FHEM/00_MQTT2_SERVER.pm
+++ b/fhem/FHEM/00_MQTT2_SERVER.pm
@@ -49,6 +49,7 @@ MQTT2_SERVER_Initialize($)
rawEvents
sslVersion
sslCertPrefix
+ topicConversion:0,1
);
use warnings 'qw';
$hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes;
@@ -540,8 +541,8 @@ MQTT2_SERVER_doPublish($$$$;$)
# Save it
my %nots = map { $_ => $server->{retain}{$_}{val} }
keys %{$server->{retain}};
- my $rname = AttrVal($server->{NAME}, "hideRetain", 0) ? ".RETAIN" : "RETAIN";
- setReadingsVal($server, $rname, toJSON(\%nots), FmtDateTime(gettimeofday()));
+ my $rname = AttrVal($server->{NAME}, "hideRetain", 0) ? ".RETAIN":"RETAIN";
+ setReadingsVal($server, $rname, toJSON(\%nots),FmtDateTime(gettimeofday()));
}
foreach my $clName (keys %{$server->{clients}}) {
@@ -553,7 +554,7 @@ MQTT2_SERVER_doPublish($$$$;$)
return if(defined($ir) && "$tp:$val" =~ m/$ir/);
my $cid = $src->{cid};
- $tp =~ s/:/_/g; # 96608
+ $tp =~ s/:/_/g if(AttrVal($serverName, "topicConversion", 1)); # 96608
if(defined($cid) || # "real" MQTT client
AttrVal($serverName, "rePublish", undef)) {
$cid = $src->{NAME} if(!defined($cid));
@@ -900,6 +901,13 @@ MQTT2_SERVER_ReadDebug($$)
also the SSL attribute.
+
+ topicConversion [1|0]
+ due to historic reasons colon (:) is converted in the topic to underscore
+ (_). Setting this attribute to 0 will disable this conversion. Default
+ is 1.
+
+
=end html