2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

AttrTemplate.pm: add checkPar and some more deteiledd error msg (Forum #108999)

git-svn-id: https://svn.fhem.de/fhem/trunk@21408 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-03-11 16:09:28 +00:00
parent b54abc0692
commit baeb2c738a

View File

@ -211,6 +211,23 @@ AttrTemplate_Set($$@)
return join("\n", @hlp);
}
if($entry eq "checkPar") {
my @ret;
foreach $entry (sort keys %templates) {
my $h = $templates{$entry};
for my $k (@{$h->{pars}}) {
my ($parname, $comment, $perl_code) = split(";",$k,3);
nex if(!$perl_code);
$perl_code =~ s/(?<!\\)DEVICE/bla/g;
$perl_code =~ s/\\DEVICE/DEVICE/g;
my $ret = eval $perl_code;
push @ret,"$entry:$parname:$@" if($@);
}
}
return "No errors found" if (!@ret);
return join("\n", @ret);
}
my $h = $templates{$entry};
return "Unknown template_entry_name $entry" if(!$h);
@ -245,7 +262,8 @@ AttrTemplate_Set($$@)
$perl_code =~ s/(?<!\\)DEVICE/$name/g;
$perl_code =~ s/\\DEVICE/DEVICE/g;
my $ret = eval $perl_code;
return "Error checking template regexp: $@" if($@);
return "ERROR executing perl-code $perl_code for param $parname: $@ "
if($@);
if(defined($ret)) {
$repl{$parname} = $ret;
next;