mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-23 14:46:24 +00:00
00_MQTT2_CLIENT.pm: no loop on auth error (Forum #92946)
git-svn-id: https://svn.fhem.de/fhem/trunk@17938 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6b434dff07
commit
816c0c0934
@ -80,6 +80,7 @@ sub
|
||||
MQTT2_CLIENT_connect($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
return if($hash->{authError});
|
||||
my $disco = (ReadingsVal($hash->{NAME}, "state", "") eq "disconnected");
|
||||
$hash->{connecting} = 1 if($disco && !$hash->{connecting});
|
||||
$hash->{nextOpenDelay} = 5;
|
||||
@ -207,6 +208,7 @@ MQTT2_CLIENT_Attr(@)
|
||||
|
||||
my %h = (clientId=>1,lwt=>1,lwtRetain=>1,subscriptions=>1,SSL=>1,username=>1);
|
||||
if($init_done && $h{$attrName}) {
|
||||
delete($hash->{authError});
|
||||
MQTT2_CLIENT_Disco($hash);
|
||||
}
|
||||
return undef;
|
||||
@ -237,6 +239,7 @@ MQTT2_CLIENT_Set($@)
|
||||
|
||||
} elsif($a[0] eq "password") {
|
||||
return "Usage: set $name password <password>" if(@a < 1);
|
||||
delete($hash->{authError});
|
||||
setKeyValue($name, $a[1]); # will delete, if argument is empty
|
||||
MQTT2_CLIENT_Disco($hash) if($init_done);
|
||||
|
||||
@ -314,6 +317,7 @@ MQTT2_CLIENT_Read($@)
|
||||
"bad user name or password", "not authorized");
|
||||
Log3 $name, 1, "$name: Connection refused, ".
|
||||
($rc <= int(@txt) ? $txt[$rc] : "unknown error $rc");
|
||||
$hash->{authError} = $rc;
|
||||
MQTT2_CLIENT_Disco($hash);
|
||||
return;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ MQTT2_DEVICE_Parse($$)
|
||||
my $ret = json2nameValue($value);
|
||||
if(keys %{$ret}) {
|
||||
$topic =~ m,.*/([^/]+),;
|
||||
my $prefix = ($1 && $1 !~m/^0x[0-9a-f]+$/) ? "${1}_" : ""; # 91394
|
||||
my $prefix = ($1 && $1 !~m/^0x[0-9a-f]+$/i) ? "${1}_" : ""; # 91394
|
||||
$add = "{ json2nameValue(\$EVENT, '$prefix') }";
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ MQTT2_DEVICE_Parse($$)
|
||||
my $cidArr = $modules{MQTT2_DEVICE}{defptr}{cid}{$newCid};
|
||||
if(!$cidArr || !int(@{$cidArr})) {
|
||||
my $devName = $newCid;
|
||||
$devName =~ s/[^a-z0-9._]/_/g;
|
||||
$devName =~ makeDeviceName($devName);
|
||||
return "UNDEFINED MQTT2_$devName MQTT2_DEVICE $newCid";
|
||||
}
|
||||
return "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user