mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 04:36:02 +00:00
00_MQTT2_SERVER.pm: add the rePublish attribute (Forum #95341)
git-svn-id: https://svn.fhem.de/fhem/trunk@18349 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d0d8bf02dc
commit
eed0b1fed6
@ -44,6 +44,7 @@ MQTT2_SERVER_Initialize($)
|
|||||||
disable:0,1
|
disable:0,1
|
||||||
disabledForIntervals
|
disabledForIntervals
|
||||||
keepaliveFactor
|
keepaliveFactor
|
||||||
|
rePublish
|
||||||
rawEvents
|
rawEvents
|
||||||
sslVersion
|
sslVersion
|
||||||
sslCertPrefix
|
sslCertPrefix
|
||||||
@ -392,36 +393,40 @@ MQTT2_SERVER_Read($@)
|
|||||||
|
|
||||||
######################################
|
######################################
|
||||||
# Call sendto for all clients + Dispatch + dotrigger if rawEvents is set
|
# Call sendto for all clients + Dispatch + dotrigger if rawEvents is set
|
||||||
# tgt is the "accept" server, src is the connection generating the data
|
# server is the "accept" server, src is the connection generating the data
|
||||||
sub
|
sub
|
||||||
MQTT2_SERVER_doPublish($$$$;$)
|
MQTT2_SERVER_doPublish($$$$;$)
|
||||||
{
|
{
|
||||||
my ($src, $tgt, $tp, $val, $retain) = @_;
|
my ($src, $server, $tp, $val, $retain) = @_;
|
||||||
$val = "" if(!defined($val));
|
$val = "" if(!defined($val));
|
||||||
$src = $tgt if(!defined($src));
|
$src = $server if(!defined($src));
|
||||||
|
|
||||||
if($retain) {
|
if($retain) {
|
||||||
my $now = gettimeofday();
|
my $now = gettimeofday();
|
||||||
my %h = ( ts=>$now, val=>$val );
|
my %h = ( ts=>$now, val=>$val );
|
||||||
$tgt->{retain}{$tp} = \%h;
|
$server->{retain}{$tp} = \%h;
|
||||||
|
|
||||||
# Save it
|
# Save it
|
||||||
my %nots = map { $_ => $tgt->{retain}{$_}{val} } keys %{$tgt->{retain}};
|
my %nots = map { $_ => $server->{retain}{$_}{val} }
|
||||||
setReadingsVal($tgt, "RETAIN", toJSON(\%nots), FmtDateTime(gettimeofday()));
|
keys %{$server->{retain}};
|
||||||
|
setReadingsVal($server,"RETAIN",toJSON(\%nots),FmtDateTime(gettimeofday()));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $clName (keys %{$tgt->{clients}}) {
|
foreach my $clName (keys %{$server->{clients}}) {
|
||||||
MQTT2_SERVER_sendto($tgt, $defs{$clName}, $tp, $val)
|
MQTT2_SERVER_sendto($server, $defs{$clName}, $tp, $val)
|
||||||
if($src->{NAME} ne $clName);
|
if($src->{NAME} ne $clName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined($src->{cid})) { # "real" MQTT client
|
my $serverName = $server->{NAME};
|
||||||
my $cid = $src->{cid};
|
my $cid = $src->{cid};
|
||||||
|
if(defined($cid) || # "real" MQTT client
|
||||||
|
AttrVal($serverName, "rePublish", undef)) {
|
||||||
|
$cid = $src->{NAME} if(!defined($cid));
|
||||||
$cid =~ s,[^a-z0-9._],_,gi;
|
$cid =~ s,[^a-z0-9._],_,gi;
|
||||||
my $ac = AttrVal($tgt->{NAME}, "autocreate", 1) ? "autocreate:":"";
|
my $ac = AttrVal($serverName, "autocreate", 1) ? "autocreate:":"";
|
||||||
Dispatch($tgt, "$ac$cid:$tp:$val", undef, !$ac);
|
Dispatch($server, "$ac$cid:$tp:$val", undef, !$ac);
|
||||||
my $re = AttrVal($tgt->{NAME}, "rawEvents", undef);
|
my $re = AttrVal($serverName, "rawEvents", undef);
|
||||||
DoTrigger($tgt->{NAME}, "$tp:$val") if($re && $tp =~ m/$re/);
|
DoTrigger($server->{NAME}, "$tp:$val") if($re && $tp =~ m/$re/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,12 +584,6 @@ MQTT2_SERVER_getStr($$)
|
|||||||
messages, but not forward them.
|
messages, but not forward them.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<a name="rawEvents"></a>
|
|
||||||
<li>rawEvents <topic-regexp><br>
|
|
||||||
Send all messages as events attributed to this MQTT2_SERVER instance.
|
|
||||||
Should only be used, if there is no MQTT2_DEVICE to process the topic.
|
|
||||||
</li><br>
|
|
||||||
|
|
||||||
<a name="keepaliveFactor"></a>
|
<a name="keepaliveFactor"></a>
|
||||||
<li>keepaliveFactor<br>
|
<li>keepaliveFactor<br>
|
||||||
the oasis spec requires a disconnect, if after 1.5 times the client
|
the oasis spec requires a disconnect, if after 1.5 times the client
|
||||||
@ -597,6 +596,20 @@ MQTT2_SERVER_getStr($$)
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<a name="rawEvents"></a>
|
||||||
|
<li>rawEvents <topic-regexp><br>
|
||||||
|
Send all messages as events attributed to this MQTT2_SERVER instance.
|
||||||
|
Should only be used, if there is no MQTT2_DEVICE to process the topic.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
|
<a name="rePublish"></a>
|
||||||
|
<li>rePublish<br>
|
||||||
|
if a topic is published from a source inside of FHEM (e.g. MQTT2_DEVICE),
|
||||||
|
it is only sent to real MQTT clients, and it will not internally
|
||||||
|
republished. By setting this attribute the topic will also be dispatched
|
||||||
|
to the FHEM internal clients.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<a name="SSL"></a>
|
<a name="SSL"></a>
|
||||||
<li>SSL<br>
|
<li>SSL<br>
|
||||||
Enable SSL (i.e. TLS)
|
Enable SSL (i.e. TLS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user