mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 12:58:13 +00:00
98_IF.pm: sleep not blocking
git-svn-id: https://svn.fhem.de/fhem/trunk@12944 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
22a3638471
commit
ece62ce8c6
@ -204,6 +204,7 @@ ParseCommandsIf($)
|
||||
my $parsedCmd="";
|
||||
my $pos=0;
|
||||
$tailBlock =~ s/;/;;/g;
|
||||
my $sleep;
|
||||
while ($tailBlock ne "") {
|
||||
if ($tailBlock=~ /^\s*\{/) { # perl block
|
||||
($beginning,$currentBlock,$err,$tailBlock)=GetBlockIf($tailBlock,'[\{\}]');
|
||||
@ -240,20 +241,34 @@ ParseCommandsIf($)
|
||||
$currentBlock=$tailBlock;
|
||||
$tailBlock="";
|
||||
}
|
||||
if ($currentBlock =~ /[^\s]/g) {
|
||||
$currentBlock =~ s/'/\\'/g;
|
||||
($currentBlock,$err)=ReplaceAllReadingsIf($currentBlock,1);
|
||||
return ($currentBlock,$err) if ($err);
|
||||
($currentBlock,$err)=EvalAllIf($currentBlock);
|
||||
$currentBlock =~ s/;/;;/g;
|
||||
return ($currentBlock,$err) if ($err);
|
||||
$parsedCmd.="fhem('".$currentBlock."')";
|
||||
$parsedCmd.=";;" if ($tailBlock);
|
||||
} else {
|
||||
$parsedCmd.=";;" if ($tailBlock);
|
||||
}
|
||||
if ($currentBlock =~ /[^\s]/g) {
|
||||
$currentBlock =~ s/'/\\'/g;
|
||||
($currentBlock,$err)=ReplaceAllReadingsIf($currentBlock,1);
|
||||
return ($currentBlock,$err) if ($err);
|
||||
($currentBlock,$err)=EvalAllIf($currentBlock);
|
||||
$currentBlock =~ s/;/;;/g;
|
||||
return ($currentBlock,$err) if ($err);
|
||||
if ($sleep) {
|
||||
$parsedCmd.=$currentBlock;
|
||||
if ($tailBlock) {
|
||||
$parsedCmd.=";;"
|
||||
} else {
|
||||
$parsedCmd.="')"
|
||||
}
|
||||
} elsif ($currentBlock =~ /^\s*sleep/) {
|
||||
$sleep=1;
|
||||
$parsedCmd.="fhem('".$currentBlock.";;";
|
||||
$parsedCmd.="')" if !($tailBlock);
|
||||
} else {
|
||||
$parsedCmd.="fhem('".$currentBlock."')";
|
||||
$parsedCmd.=";;" if ($tailBlock);
|
||||
}
|
||||
} else {
|
||||
$parsedCmd.=";;" if ($tailBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return($parsedCmd,"");
|
||||
}
|
||||
|
||||
@ -336,6 +351,8 @@ CommandIF($$)
|
||||
1;
|
||||
|
||||
=pod
|
||||
=item summary FHEM IF-command
|
||||
=item summary_DE FHEM IF-Befehl
|
||||
=begin html
|
||||
|
||||
<a name="IF"></a>
|
||||
@ -433,6 +450,10 @@ CommandIF($$)
|
||||
<br>
|
||||
<code>define check at *10:00 IF ([indoor] eq "on") (set lamp1 on,define a_test at +00:10 set lampe2 on;;set lampe3 off;;set temp desired 20)<br></code>
|
||||
<br>
|
||||
sleep can be used with comma, it is not blocking:<br>
|
||||
<br>
|
||||
<code>define check at *10:00 IF ([indoor] eq "on") (sleep 2,set lampe1 on,sleep 3,set lampe2 on)</code><br>
|
||||
<br>
|
||||
Time-dependent switch: In the period 20:00 to 22:00 clock the light should go off when it was on and I leave the room:<br>
|
||||
<br>
|
||||
<code>define n_lamp_off notify sensor IF ($hms gt "20:00" and $hms lt "22:00" and [sensor] eq "absent") (set lamp:FILTER=STATE!=off off)<br></code>
|
||||
@ -558,6 +579,10 @@ CommandIF($$)
|
||||
<br>
|
||||
<code>define check at *10:00 IF ([indoor] eq "on") (set lamp1 on,define a_test at +00:10 set lampe2 on;;set lampe3 off;;set temp desired 20)<br></code>
|
||||
<br>
|
||||
sleep kann mit Komma verwendet werden, dabei wirkt das sleep nicht blockierend:<br>
|
||||
<br>
|
||||
<code>define check at *10:00 IF ([indoor] eq "on") (sleep 2,set lampe1 on,sleep 3,set lampe2 on)</code><br>
|
||||
<br>
|
||||
Zeitabhängig schalten: In der Zeit zwischen 20:00 und 22:00 Uhr soll das Licht ausgehen, wenn es an war und ich den Raum verlasse:<br>
|
||||
<br>
|
||||
<code>define n_lamp_off notify sensor IF ($hms gt "20:00" and $hms lt "22:00" and [sensor] eq "absent") (set lamp:FILTER=STATE!=off off)<br></code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user