mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 10:46:53 +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:
parent
df17a1fa41
commit
7c4caae9b3
@ -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
|
||||
</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 <username><br>
|
||||
set the username. The password is set via the set command, and is stored
|
||||
|
@ -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.
|
||||
</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
|
||||
|
Loading…
x
Reference in New Issue
Block a user