98_DOIF.pm new option: init_-block

git-svn-id: https://svn.fhem.de/fhem/trunk@25663 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Damian 2022-02-09 17:05:11 +00:00
parent 62577537fa
commit f386a73267

View File

@ -2830,13 +2830,15 @@ DOIF_Notify($$)
readingsEndUpdate($hash, 0);
}
if (defined $hash->{perlblock}{init}) {
if (($ret,$err)=DOIF_CheckCond($hash,$hash->{perlblock}{init})) {
for (my $i=0; $i < keys %{$hash->{perlblock}};$i++) {
if ($hash->{perlblock}{$i} eq "init" or $hash->{perlblock}{$i} =~ "^init_" ) {
if (($ret,$err)=DOIF_CheckCond($hash,$i)) {
if ($err) {
Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block init" if ($ret != -1);
readingsSingleUpdate ($hash, "block_init", $err,0);
Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block $hash->{perlblock}{$i}" if ($ret != -1);
readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", $err,0);
} else {
readingsSingleUpdate ($hash, "block_init", "executed",0);
readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", "executed",0);
}
}
}
}
@ -3452,9 +3454,9 @@ sub DOIF_Perlblock
return ($perlblock,$err) if ($err);
$hash->{condition}{$i}=$perlblock;
$hash->{perlblock}{$i}=$blockname ? $blockname:sprintf("block_%02d",($i+1));
if ($blockname eq "init") {
$hash->{perlblock}{init}=$i;
}
#if ($blockname eq "init") {
# $hash->{perlblock}{init}=$i;
#}
$i++;
}
}
@ -3555,14 +3557,16 @@ CmdDoIfPerl($$)
# }
# $i++;
# }
if (defined $hash->{perlblock}{init}) {
if ($init_done) {
if (($ret,$err)=DOIF_CheckCond($hash,$hash->{perlblock}{init})) {
for (my $i=0; $i < keys %{$hash->{perlblock}};$i++) {
if ($hash->{perlblock}{$i} eq "init" or $hash->{perlblock}{$i} =~ "^init_" ) {
if (($ret,$err)=DOIF_CheckCond($hash,$i)) {
if ($err) {
Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block init" if ($ret != -1);
readingsSingleUpdate ($hash, "block_init", $err,0);
Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block $hash->{perlblock}{$i}" if ($ret != -1);
readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", $err,0);
} else {
readingsSingleUpdate ($hash, "block_init", "executed",0);
readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", "executed",0);
}
}
}
}