mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-08 07:24:21 +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 $parsedCmd="";
|
||||||
my $pos=0;
|
my $pos=0;
|
||||||
$tailBlock =~ s/;/;;/g;
|
$tailBlock =~ s/;/;;/g;
|
||||||
|
my $sleep;
|
||||||
while ($tailBlock ne "") {
|
while ($tailBlock ne "") {
|
||||||
if ($tailBlock=~ /^\s*\{/) { # perl block
|
if ($tailBlock=~ /^\s*\{/) { # perl block
|
||||||
($beginning,$currentBlock,$err,$tailBlock)=GetBlockIf($tailBlock,'[\{\}]');
|
($beginning,$currentBlock,$err,$tailBlock)=GetBlockIf($tailBlock,'[\{\}]');
|
||||||
@ -247,13 +248,27 @@ ParseCommandsIf($)
|
|||||||
($currentBlock,$err)=EvalAllIf($currentBlock);
|
($currentBlock,$err)=EvalAllIf($currentBlock);
|
||||||
$currentBlock =~ s/;/;;/g;
|
$currentBlock =~ s/;/;;/g;
|
||||||
return ($currentBlock,$err) if ($err);
|
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.="fhem('".$currentBlock."')";
|
||||||
$parsedCmd.=";;" if ($tailBlock);
|
$parsedCmd.=";;" if ($tailBlock);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$parsedCmd.=";;" if ($tailBlock);
|
$parsedCmd.=";;" if ($tailBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return($parsedCmd,"");
|
return($parsedCmd,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +351,8 @@ CommandIF($$)
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
=item summary FHEM IF-command
|
||||||
|
=item summary_DE FHEM IF-Befehl
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="IF"></a>
|
<a name="IF"></a>
|
||||||
@ -433,6 +450,10 @@ CommandIF($$)
|
|||||||
<br>
|
<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>
|
<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>
|
<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>
|
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>
|
<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>
|
<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>
|
<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>
|
<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>
|
<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>
|
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>
|
<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>
|
<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