2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

MQTT2_SERVER/MQTT2_CLIENT: addd topicConversion attribute (Forum #129206)

git-svn-id: https://svn.fhem.de/fhem/trunk@26405 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-09-16 18:15:35 +00:00
parent df17a1fa41
commit 7c4caae9b3
2 changed files with 22 additions and 6 deletions

View File

@ -56,6 +56,7 @@ MQTT2_CLIENT_Initialize($)
subscriptions
SSL
sslargs
topicConversion:0,1
username
);
use warnings 'qw';
@ -533,7 +534,7 @@ MQTT2_CLIENT_Read($@)
$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
</li><br>
<a id="MQTT2_CLIENT-attr-topicConversion"></a>
<li>topicConversion [1|0]<br>
due to historic reasons colon (:) is converted in the topic to underscore
(_). Setting this attribute to 0 will disable this conversion. Default
is 1.
</li><br>
<a id="MQTT2_CLIENT-attr-username"></a>
<li>username &lt;username&gt;<br>
set the username. The password is set via the set command, and is stored

View File

@ -49,6 +49,7 @@ MQTT2_SERVER_Initialize($)
rawEvents
sslVersion
sslCertPrefix
topicConversion:0,1
);
use warnings 'qw';
$hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes;
@ -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.
</li><br>
<a id="MQTT2_SERVER-attr-topicConversion"></a>
<li>topicConversion [1|0]<br>
due to historic reasons colon (:) is converted in the topic to underscore
(_). Setting this attribute to 0 will disable this conversion. Default
is 1.
</li><br>
</ul>
</ul>
=end html