From 4a9a958bd4947209a93ddea744a5cc84291ce93b Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 1 Apr 2023 20:10:06 +0000 Subject: [PATCH] 00_MQTT2_CLIENT.pm: landroid worx / AWS-IOT stuff (Forum #111959) git-svn-id: https://svn.fhem.de/fhem/trunk@27382 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_MQTT2_CLIENT.pm | 23 ++++++++++++++++++++++- fhem/FHEM/HttpUtils.pm | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm index c519ac3ec..b6ea18155 100644 --- a/fhem/FHEM/00_MQTT2_CLIENT.pm +++ b/fhem/FHEM/00_MQTT2_CLIENT.pm @@ -40,6 +40,7 @@ MQTT2_CLIENT_Initialize($) clientId clientOrder connectTimeout + connectFn disable:1,0 disabledForIntervals disconnectAfter @@ -97,7 +98,17 @@ MQTT2_CLIENT_Define($$) $hash->{connecting} = 1; $hash->{nrConnects} = 0; - InternalTimer(1, "MQTT2_CLIENT_connect", $hash, 0); # need attributes + InternalTimer(1, sub($){ + my $cfn = AttrVal($hash->{NAME}, "connectFn", undef); + if($cfn) { + my %specials= ("%NAME" => $hash->{NAME}); + $cfn = EvalSpecials($cfn, %specials); + AnalyzeCommand(undef, $cfn); # $cfn calls connect + } else { + MQTT2_CLIENT_connect($hash); + } + }, $hash, 0); + return undef; } @@ -136,6 +147,8 @@ MQTT2_CLIENT_doinit($) if($hash->{connecting} == 1) { my $usr = AttrVal($name, "username", ""); my ($err, $pwd) = getKeyValue($name); + $usr = $hash->{".usr"} if($hash->{".usr"}); # AWS/WORX + $pwd = $hash->{".pwd"} if($hash->{".pwd"}); $pwd = undef if($usr eq ""); if($err) { Log 1, "ERROR: $err"; @@ -876,6 +889,14 @@ MQTT2_CLIENT_feedTheList($$$) Note: Changing the attribute affects _all_ MQTT2_CLIENT instances. + +