mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-15 16:19:11 +00:00
fhem.pl: tune the set {} feature (Forum #38276)
git-svn-id: https://svn.fhem.de/fhem/trunk@8808 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e0fced9909
commit
46f0a1660c
@ -161,6 +161,28 @@ FHZ_Ready($)
|
||||
return ($InBytes>0);
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
CommandChain($$)
|
||||
{
|
||||
my ($retry, $list) = @_;
|
||||
my $ov = $attr{global}{verbose};
|
||||
my $oid = $init_done;
|
||||
|
||||
$init_done = 0;
|
||||
$attr{global}{verbose} = 1;
|
||||
foreach my $cmd (@{$list}) {
|
||||
for(my $n = 0; $n < $retry; $n++) {
|
||||
Log 1, sprintf("Trying again $cmd (%d out of %d)", $n+1,$retry) if($n>0);
|
||||
my $ret = AnalyzeCommand(undef, $cmd);
|
||||
last if(!defined($ret) || $ret !~ m/Timeout/);
|
||||
}
|
||||
}
|
||||
$attr{global}{verbose} = $ov;
|
||||
$init_done = $oid;
|
||||
}
|
||||
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FHZ_Set($@)
|
||||
|
32
fhem/fhem.pl
32
fhem/fhem.pl
@ -49,7 +49,6 @@ sub AssignIoPort($;$);
|
||||
sub AttrVal($$$);
|
||||
sub CallFn(@);
|
||||
sub CheckDuplicate($$@);
|
||||
sub CommandChain($$);
|
||||
sub Debug($);
|
||||
sub DoSet(@);
|
||||
sub Dispatch($$$);
|
||||
@ -1495,10 +1494,10 @@ ReplaceSetMagic(@) # Forum #38276
|
||||
my $x = ReadingsVal($1,$2,""); $x eq "" ? "[$1:$2]" : $x
|
||||
}/egi;
|
||||
|
||||
$a =~ s/{([^}]+)}/{
|
||||
$a =~ s/({[^}]+})/{
|
||||
my $x = eval $1;
|
||||
Log 1, "ReplaceSetMagic: $1 -> $@" if($@);
|
||||
$@ ? "{$1}" : $x
|
||||
($@ || ref($x) eq "HASH") ? $1 : $x
|
||||
}/eg;
|
||||
|
||||
return split(" ", $a);
|
||||
@ -2780,27 +2779,6 @@ FmtTime($)
|
||||
return sprintf("%02d:%02d:%02d", $t[2], $t[1], $t[0]);
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
CommandChain($$)
|
||||
{
|
||||
my ($retry, $list) = @_;
|
||||
my $ov = $attr{global}{verbose};
|
||||
my $oid = $init_done;
|
||||
|
||||
$init_done = 0; # Rudi: ???
|
||||
$attr{global}{verbose} = 1; # ???
|
||||
foreach my $cmd (@{$list}) {
|
||||
for(my $n = 0; $n < $retry; $n++) {
|
||||
Log 1, sprintf("Trying again $cmd (%d out of %d)", $n+1,$retry) if($n>0);
|
||||
my $ret = AnalyzeCommand(undef, $cmd);
|
||||
last if(!defined($ret) || $ret !~ m/Timeout/);
|
||||
}
|
||||
}
|
||||
$attr{global}{verbose} = $ov;
|
||||
$init_done = $oid;
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
ResolveDateWildcards($@)
|
||||
@ -2856,7 +2834,7 @@ EvalSpecials($%)
|
||||
return $exec;
|
||||
}
|
||||
|
||||
$exec =~ s/%%/____/g if($featurelevel < 5.7);
|
||||
$exec =~ s/%%/____/g if($featurelevel <= 5.6);
|
||||
|
||||
|
||||
# perform macro substitution
|
||||
@ -2865,14 +2843,14 @@ EvalSpecials($%)
|
||||
$extsyntax+= ($exec =~ s/$special/$specials{$special}/g);
|
||||
}
|
||||
|
||||
if($featurelevel < 5.7) {
|
||||
if($featurelevel <= 5.6) {
|
||||
if(!$extsyntax) {
|
||||
$exec =~ s/%/$specials{"%EVENT"}/g;
|
||||
}
|
||||
$exec =~ s/____/%/g;
|
||||
}
|
||||
|
||||
if($featurelevel < 5.7) {
|
||||
if($featurelevel <= 5.6) {
|
||||
$exec =~ s/@@/____/g;
|
||||
$exec =~ s/@/$specials{"%NAME"}/g;
|
||||
$exec =~ s/____/@/g;
|
||||
|
Loading…
x
Reference in New Issue
Block a user