From e6bb4159320c0f6a9023aca829f0b441c0b4c69f Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 12 Jun 2021 10:04:13 +0000 Subject: [PATCH] 00_MQTT2_CLIENT.pm: attr disable prevents connection (Forum #111959) git-svn-id: https://svn.fhem.de/fhem/trunk@24617 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_MQTT2_CLIENT.pm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm index 66bccc616..5a082d3b5 100644 --- a/fhem/FHEM/00_MQTT2_CLIENT.pm +++ b/fhem/FHEM/00_MQTT2_CLIENT.pm @@ -96,7 +96,7 @@ sub MQTT2_CLIENT_connect($) { my ($hash) = @_; - return if($hash->{authError}); + return if($hash->{authError} || AttrVal($hash->{NAME}, "disable", 0)); my $disco = (DevIo_getState($hash) eq "disconnected"); $hash->{connecting} = 1 if($disco && !$hash->{connecting}); $hash->{nextOpenDelay} = 5; @@ -349,6 +349,16 @@ MQTT2_CLIENT_Attr(@) } } + if($attrName eq "disable") { + if($type eq "set" && $param[0]) { + MQTT2_CLIENT_Disco($hash,1) + if(DevIo_getState($hash) ne "disconnected"); + + } else { + InternalTimer(0, \&MQTT2_CLIENT_connect, $hash, 1) + if(DevIo_getState($hash) ne "opened"); + } + } return undef; } @@ -747,8 +757,12 @@ MQTT2_CLIENT_getStr($$)
  • disable
    - disabledForIntervals
    - disable dispatching of messages. + disable the connection to the server. +

  • + +
  • disabledForIntervals
    + disable sending or dispatching of messages but not the connection to the + server.