mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
Multi-Holiday allowed
git-svn-id: https://svn.fhem.de/fhem/trunk@1622 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0cd9f17fec
commit
5a1f00ab48
@ -43,6 +43,7 @@
|
||||
- feature: new parameter <changed> for updatefhem added (M. Fischer)
|
||||
new global attribute <exclude_from_update> added (M. Fischer)
|
||||
- feature: optional telnet password added / telnet port is optional
|
||||
- feature: holiday returns all matches, not only the first.
|
||||
|
||||
- 2011-12-31 (5.2)
|
||||
- bugfix: applying smallscreen attributes to firefox/opera
|
||||
|
@ -62,17 +62,18 @@ holiday_refresh($$)
|
||||
|
||||
my $fname = $attr{global}{modpath} . "/FHEM/" . $hash->{NAME} . ".holiday";
|
||||
return "Can't open $fname: $!" if(!open(FH, $fname));
|
||||
my $found = "none";
|
||||
my @foundList;
|
||||
|
||||
while(my $l = <FH>) {
|
||||
next if($l =~ m/^\s*#/);
|
||||
next if($l =~ m/^\s*$/);
|
||||
chomp($l);
|
||||
my $found;
|
||||
|
||||
if($l =~ m/^1/) { # Exact date: 1 MM-DD Holiday
|
||||
my @args = split(" +", $l, 3);
|
||||
if($args[1] eq $fordate) {
|
||||
$found = $args[2];
|
||||
last;
|
||||
}
|
||||
|
||||
} elsif($l =~ m/^2/) { # Easter date: 2 +1 Ostermontag
|
||||
@ -98,7 +99,6 @@ holiday_refresh($$)
|
||||
next if($mday != $fd[3] || $mmonth != $fd[4]+1);
|
||||
$found = $a[2];
|
||||
Log 4, "$name: Match day: $a[2]\n";
|
||||
last;
|
||||
|
||||
} elsif($l =~ m/^3/) { # Relative date: 3 -1 Mon 03 Holiday
|
||||
my @a = split(" +", $l, 5);
|
||||
@ -123,13 +123,11 @@ holiday_refresh($$)
|
||||
}
|
||||
|
||||
$found = $a[4];
|
||||
last;
|
||||
|
||||
} elsif($l =~ m/^4/) { # Interval: 4 MM-DD MM-DD Holiday
|
||||
my @args = split(" +", $l, 4);
|
||||
if($args[1] le $fordate && $args[2] ge $fordate) {
|
||||
$found = $args[3];
|
||||
last;
|
||||
}
|
||||
|
||||
} elsif($l =~ m/^5/) { # nth weekday since MM-DD / before MM-DD
|
||||
@ -155,27 +153,29 @@ holiday_refresh($$)
|
||||
$tgtmin -= $1*$weeksecs; # Minimum: target date minus $1 weeks
|
||||
$tgtmax = $tgtmin+$weeksecs; # Maximum: one week after minimum
|
||||
# needs to be lower than max and greater than or equal to min
|
||||
if ( ($cd ge $tgtmin) && ( $cd lt $tgtmax) ) {
|
||||
$found=$a[5];
|
||||
last;
|
||||
if( ($cd ge $tgtmin) && ( $cd lt $tgtmax) ) {
|
||||
$found=$a[5];
|
||||
}
|
||||
} elsif ( $a[1] =~ /^\+?([0-9])*$/ ) {
|
||||
$tgtmin += ($1-1)*$weeksecs; # Minimum: target date plus $1-1 weeks
|
||||
$tgtmax = $tgtmin+$weeksecs; # Maximum: one week after minimum
|
||||
# needs to be lower than or equal to max and greater min
|
||||
if ( ($cd gt $tgtmin) && ( $cd le $tgtmax) ) {
|
||||
$found=$a[5];
|
||||
last;
|
||||
if( ($cd gt $tgtmin) && ( $cd le $tgtmax) ) {
|
||||
$found=$a[5];
|
||||
}
|
||||
} else {
|
||||
Log 1, "Wrong distance spec: $l";
|
||||
next;
|
||||
}
|
||||
}
|
||||
push @foundList, $found if($found);
|
||||
|
||||
}
|
||||
close(FH);
|
||||
|
||||
push @foundList, "none" if(!int(@foundList));
|
||||
my $found = join(", ", @foundList);
|
||||
|
||||
RemoveInternalTimer($name);
|
||||
$nt -= ($lt[2]*3600+$lt[1]*60+$lt[0]); # Midnight
|
||||
$nt += 86400 + 2; # Tomorrow
|
||||
|
@ -9165,14 +9165,14 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK. <br> You need to define an RFXtrx433
|
||||
<br><br>
|
||||
Define a set of holidays. The module will try to open the file
|
||||
<name>.holiday in the <a href="#modpath">modpath</a>/FHEM directory.
|
||||
If an entry in the holiday file matches the current day, then the STATE of
|
||||
If entries in the holiday file match the current day, then the STATE of
|
||||
this holiday instance displayed in the <a href="#list">list</a> command
|
||||
will be set to the holiday, else the state is set to the text none. Most
|
||||
probably you'll want to query this value in some perl script: see Value() in
|
||||
the <a href="#perl">perl</a> section or the global attribute <a
|
||||
href="#holiday2we"> holiday2we</a>.<br>
|
||||
The file will be reread once every night, to compute the value for the
|
||||
current day, and by each get command (see below).<br>
|
||||
will be set to the corresponding values, else the state is set to the text
|
||||
none. Most probably you'll want to query this value in some perl script:
|
||||
see Value() in the <a href="#perl">perl</a> section or the global attribute
|
||||
<a href="#holiday2we"> holiday2we</a>.<br> The file will be reread once
|
||||
every night, to compute the value for the current day, and by each get
|
||||
command (see below).<br>
|
||||
<br>
|
||||
|
||||
Holiday file definition:<br>
|
||||
|
Loading…
Reference in New Issue
Block a user