2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

fhem.pl: rework global attribute regexp checking, add devStateIcon (Forum #71897)

git-svn-id: https://svn.fhem.de/fhem/trunk@14284 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-05-14 17:05:43 +00:00
parent 2b4e41b23f
commit 0c30050586
2 changed files with 9 additions and 8 deletions

View File

@ -3419,7 +3419,7 @@ FW_widgetOverride($$)
</ul> </ul>
Second form:<br> Second form:<br>
<ul> <ul>
Perl regexp enclosed in {}. If the code returns undef, then the default Perl code enclosed in {}. If the code returns undef, then the default
icon is used, if it retuns a string enclosed in <>, then it is icon is used, if it retuns a string enclosed in <>, then it is
interpreted as an html string. Else the string is interpreted as a interpreted as an html string. Else the string is interpreted as a
devStateIcon of the first fom, see above. devStateIcon of the first fom, see above.

View File

@ -2721,15 +2721,16 @@ CommandAttr($$)
} }
} }
my %ra = ("suppressReading" => 1, my %ra = ("suppressReading" => { s=>"\n" },
"event-on-update-reading" => 1, "event-on-update-reading" => { s=>"," },
"event-on-change-reading" => 2, "event-on-change-reading" => { s=>",", r=>":.*" },
"timestamp-on-change-reading"=> 1, "timestamp-on-change-reading"=> { s=>"," },
"event-min-interval" => 2); "event-min-interval" => { s=>",", r=>";.*" },
"devStateIcon" => { s=>" ", r=>":.*" } );
if(defined($a[2]) && $ra{$attrName}) { if(defined($a[2]) && $ra{$attrName}) {
my $lval = $a[2]; my $lval = $a[2];
$lval =~ s/:.*// if($ra{$attrName} == 2); for my $v (split($ra{$attrName}{s}, $lval)) {
for my $v (split(",", $lval)) { $v =~ s/$ra{$attrName}{r}// if($ra{$attrName}{r});
my $err = "Argument $v for attr $sdev $a[1] is not a valid regexp"; my $err = "Argument $v for attr $sdev $a[1] is not a valid regexp";
return "$err: use .* instead of *" if($v =~ /^\*/); # no err in eval!? return "$err: use .* instead of *" if($v =~ /^\*/); # no err in eval!?
eval { "Hallo" =~ m/^$v$/ }; eval { "Hallo" =~ m/^$v$/ };