2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

98_DOIF.pm: $we, $wte multiple holiday files now possible, fixed: DOELSE {Perl}

git-svn-id: https://svn.fhem.de/fhem/trunk@18890 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Damian 2019-03-13 18:56:41 +00:00
parent b2c8a30876
commit 8a07906192

View File

@ -1874,10 +1874,11 @@ sub DOIF_we($) {
my ($wday)=@_; my ($wday)=@_;
my $we = (($wday==0 || $wday==6) ? 1 : 0); my $we = (($wday==0 || $wday==6) ? 1 : 0);
if(!$we) { if(!$we) {
my $h2we = $attr{global}{holiday2we}; foreach my $h2we (split(",", AttrVal("global", "holiday2we", ""))) {
if($h2we && Value($h2we)) { if($h2we && Value($h2we)) {
my ($a, $b) = ReplaceEventMap($h2we, [$h2we, Value($h2we)], 0); my ($a, $b) = ReplaceEventMap($h2we, [$h2we, Value($h2we)], 0);
$we = 1 if($b ne "none"); $we = 1 if($b ne "none");
}
} }
} }
return $we; return $we;
@ -1887,10 +1888,11 @@ sub DOIF_tomorrow_we($) {
my ($wday)=@_; my ($wday)=@_;
my $we = (($wday==5 || $wday==6) ? 1 : 0); my $we = (($wday==5 || $wday==6) ? 1 : 0);
if(!$we) { if(!$we) {
my $h2we = $attr{global}{holiday2we}; foreach my $h2we (split(",", AttrVal("global", "holiday2we", ""))) {
if($h2we && ReadingsVal($h2we,"tomorrow",0)) { if($h2we && ReadingsVal($h2we,"tomorrow",0)) {
my ($a, $b) = ReplaceEventMap($h2we, [$h2we, ReadingsVal($h2we,"tomorrow",0)], 0); my ($a, $b) = ReplaceEventMap($h2we, [$h2we, ReadingsVal($h2we,"tomorrow",0)], 0);
$we = 1 if($b ne "none"); $we = 1 if($b ne "none");
}
} }
} }
return $we; return $we;
@ -3118,12 +3120,18 @@ CmdDoIf($$)
return ($tail,"expected DOELSE"); return ($tail,"expected DOELSE");
} }
$j=0; $j=0;
while ($tail =~ /^\s*\(/) { while ($tail =~ /^\s*(\(|\{)/) {
($beginning,$else_cmd_ori,$err,$tail)=GetBlockDoIf($tail,'[\(\)]'); if ($tail =~ /^\s*\(/) {
return ($else_cmd_ori,$err) if ($err); ($beginning,$else_cmd_ori,$err,$tail)=GetBlockDoIf($tail,'[\(\)]');
($else_cmd,$err)=ParseCommandsDoIf($hash,$else_cmd_ori,0); return ($else_cmd_ori,$err) if ($err);
return ($else_cmd,$err) if ($err); } elsif ($tail =~ /^\s*\{/) {
$hash->{do}{$last_do+1}{$j++}=$else_cmd_ori; ($beginning,$else_cmd_ori,$err,$tail)=GetBlockDoIf($tail,'[\{\}]');
return ($else_cmd_ori,$err) if ($err);
$else_cmd_ori="{".$else_cmd_ori."}";
}
($else_cmd,$err)=ParseCommandsDoIf($hash,$else_cmd_ori,0);
return ($else_cmd,$err) if ($err);
$hash->{do}{$last_do+1}{$j++}=$else_cmd_ori;
} }
$hash->{do}{$last_do+1}{0}=$else_cmd_ori if ($j==0); #doelse without brackets $hash->{do}{$last_do+1}{0}=$else_cmd_ori if ($j==0); #doelse without brackets
} }