From f386a732675f5fb40642e3abe192ca4e21d6d0ae Mon Sep 17 00:00:00 2001 From: Damian <> Date: Wed, 9 Feb 2022 17:05:11 +0000 Subject: [PATCH] 98_DOIF.pm new option: init_-block git-svn-id: https://svn.fhem.de/fhem/trunk@25663 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_DOIF.pm | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm index 902f6a785..30d71a7f6 100644 --- a/fhem/FHEM/98_DOIF.pm +++ b/fhem/FHEM/98_DOIF.pm @@ -2830,13 +2830,15 @@ DOIF_Notify($$) readingsEndUpdate($hash, 0); } - if (defined $hash->{perlblock}{init}) { - if (($ret,$err)=DOIF_CheckCond($hash,$hash->{perlblock}{init})) { - if ($err) { - Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block init" if ($ret != -1); - readingsSingleUpdate ($hash, "block_init", $err,0); - } else { - readingsSingleUpdate ($hash, "block_init", "executed",0); + 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 $hash->{perlblock}{$i}" if ($ret != -1); + readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", $err,0); + } else { + 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})) { - if ($err) { - Log3 $hash->{NAME},4,"$hash->{NAME}: $err in perl block init" if ($ret != -1); - readingsSingleUpdate ($hash, "block_init", $err,0); - } else { - readingsSingleUpdate ($hash, "block_init", "executed",0); + if ($init_done) { + 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 $hash->{perlblock}{$i}" if ($ret != -1); + readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", $err,0); + } else { + readingsSingleUpdate ($hash, "block_$hash->{perlblock}{$i}", "executed",0); + } } } }