10_MQTT2_DEVICE.pm: do not escape value for perl

fhem.pl: check if associatedWith exists


git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18381 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-01-22 18:29:59 +00:00
parent 48848d6766
commit 0d2b4b7bba
2 changed files with 4 additions and 4 deletions

View File

@ -179,9 +179,9 @@ MQTT2_DEVICE_Parse($$)
if(!$add) { if(!$add) {
$topic =~ m,.*/([^/]+),; $topic =~ m,.*/([^/]+),;
$add = ($1 ? $1 : $topic); $add = ($1 ? $1 : $topic);
$add = makeReadingName($add); # Convert non-valid characters to _
} }
$add = makeReadingName($add); # Convert non-valid characters to _
$topic =~ s,([\^\$\[\]()\.\\]),\\$1,g; $topic =~ s,([\^\$\[\]()\.\\]),\\$1,g;
for my $ch (@{$cidArr}) { for my $ch (@{$cidArr}) {
@ -193,7 +193,7 @@ MQTT2_DEVICE_Parse($$)
CommandAttr(undef, "$nn readingList $rl$regex $add") CommandAttr(undef, "$nn readingList $rl$regex $add")
if(index($rl, $regex) == -1); # Forum #84372 if(index($rl, $regex) == -1); # Forum #84372
setReadingsVal($defs{$nn}, "associatedWith", $parentBridge, TimeNow()) setReadingsVal($defs{$nn}, "associatedWith", $parentBridge, TimeNow())
if($parentBridge); if($parentBridge && $defs{$nn});
} }
MQTT2_DEVICE_Parse($iodev, $msg); MQTT2_DEVICE_Parse($iodev, $msg);
}, undef); }, undef);

View File

@ -2651,7 +2651,7 @@ CommandRename($$)
my $aw = ReadingsVal($d, "associatedWith", ""); my $aw = ReadingsVal($d, "associatedWith", "");
next if($aw !~ m/\b$old\b/); next if($aw !~ m/\b$old\b/);
$aw =~ s/\b$old\b/$new/; $aw =~ s/\b$old\b/$new/;
setReadingsVal($defs{$d}, "associatedWith", $aw, TimeNow()); setReadingsVal($defs{$d}, "associatedWith", $aw, TimeNow()) if($defs{$d});
} }
addStructChange("rename", $new, $param); addStructChange("rename", $new, $param);
@ -5664,7 +5664,7 @@ getPawList($)
} }
} }
my $aw = ReadingsVal($d, "associatedWith", ""); # Explicit link my $aw = ReadingsVal($d, "associatedWith", ""); # Explicit link
push(@dob, split("[ ,]",$aw)) if($aw); push(@dob, grep { $defs{$_} } split("[ ,]",$aw)) if($aw);
return @dob; return @dob;
} }