10_MQTT2_DEVICE.pm: check the regexp in the readingList (Forum #126969)

git-svn-id: https://svn.fhem.de/fhem/trunk@25888 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-03-27 10:22:58 +00:00
parent 7b212f85ab
commit 493ca454f7
2 changed files with 5 additions and 1 deletions

View File

@ -474,6 +474,10 @@ MQTT2_DEVICE_Attr($$)
return "$dev attr $attrName: more parameters needed" if(!$par2);
if($atype eq "reading") {
$par1 =~ s/\$[a-z0-9_]+/\.\*/gi;
eval { "Hallo" =~ m/^$par1$/ };
return "Bad regexp in $dev readingList: $@" if($@);
if($par2 =~ m/^{.*}\s*$/) {
my %v = ("%TOPIC"=>1, "%EVENT"=>"0 1 2 3 4 5 6 7 8 9",
"%NAME"=>$dev, "%CID"=>"clientId", "%JSONMAP"=>"");

View File

@ -55,7 +55,7 @@ notify_Define($$)
# Checking for misleading regexps
return "Bad regexp: starting with *" if($re =~ m/^\*/);
eval { "Hallo" =~ m/^$re$/ };
return "Bad regexp: $@" if($@);
return "Bad regexp in $name definition: $@" if($@);
$hash->{REGEXP} = $re;
my %specials= (
"%NAME" => $name,