diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm index ae8ad6d50..52c64ee62 100644 --- a/fhem/FHEM/00_MQTT2_CLIENT.pm +++ b/fhem/FHEM/00_MQTT2_CLIENT.pm @@ -177,7 +177,8 @@ MQTT2_CLIENT_Disco($;$) RemoveInternalTimer($hash); $hash->{connecting} = 1 if(!$isUndef); my $ond = AttrVal($hash->{NAME}, "msgBeforeDisconnect", ""); - MQTT2_CLIENT_doPublish($hash, split(" ", $ond, 2), 0, 1) if($ond); + MQTT2_CLIENT_doPublish($hash, $2, $3, $1) + if($ond =~ m/^(-r\s)?([^\s]*)\s*(.*)$/); MQTT2_CLIENT_send($hash, pack("C",0xE0).pack("C",0), 1); # DISCONNECT $isUndef ? DevIo_CloseDev($hash) : DevIo_Disconnected($hash); } @@ -325,7 +326,8 @@ MQTT2_CLIENT_Read($@) if($hash->{connecting}) { delete($hash->{connecting}); my $onc = AttrVal($name, "msgAfterConnect", ""); - MQTT2_CLIENT_doPublish($hash, split(" ", $onc, 2)) if($onc); + MQTT2_CLIENT_doPublish($hash, $2, $3, $1) + if($onc =~ m/^(-r\s)?([^\s]*)\s*(.*)$/); } } elsif($cpt eq "PINGRESP") { # ignore it @@ -569,13 +571,15 @@ MQTT2_CLIENT_getStr($$)
-
  • msgAfterConnect topic message
    - publish the topic after each connect or reconnect. +
  • msgAfterConnect [-r] topic message
    + publish the topic after each connect or reconnect.
    + If the optional -r is specified, then the publish sets the retain flag.

  • -
  • msgBeforeDisconnect topic message
    - publish the topic bofore each disconnect. +
  • msgBeforeDisconnect [-r] topic message
    + publish the topic bofore each disconnect.
    + If the optional -r is specified, then the publish sets the retain flag.