2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 12:58:13 +00:00

10_MQTT2_DEVICE.pm: fix autocreate of strange topic strings (Forum #96189)

git-svn-id: https://svn.fhem.de/fhem/trunk@18361 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-01-21 20:26:35 +00:00
parent 39b7fa75e2
commit 1e9fa37d04

View File

@ -181,13 +181,17 @@ MQTT2_DEVICE_Parse($$)
$add = ($1 ? $1 : $topic);
}
$add = makeReadingName($add); # Convert non-valid characters to _
$topic =~ s,([\^\$\[\]()\.\\]),\\$1,g;
for my $ch (@{$cidArr}) {
my $nn = $ch->{NAME};
next if(!AttrVal($nn, "autocreate", 1));
my $rl = AttrVal($nn, "readingList", "");
$rl .= "\n" if($rl);
my $regexpCid = ($cid eq $newCid ? "$cid:" : "");
CommandAttr(undef, "$nn readingList $rl${regexpCid}$topic:.* $add");
my $regex = ($cid eq $newCid ? "$cid:" : "").$topic.":.*";
CommandAttr(undef, "$nn readingList $rl$regex $add")
if(index($rl, $regex) == -1); # Forum #84372
setReadingsVal($defs{$nn}, "associatedWith", $parentBridge, TimeNow())
if($parentBridge);
}
@ -502,6 +506,8 @@ JSEND
}
}
#########################
# Used for the graphical representation in Bridge devices. See Fn above.
sub
MQTT2_DEVICE_nlData($)
{