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

57_Calendar: cutoffOlderThan also removes recurring events when the series has ended.

git-svn-id: https://svn.fhem.de/fhem/trunk@17421 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2018-09-28 19:18:37 +00:00
parent 6fbed78449
commit 360e06f3b2
2 changed files with 33 additions and 17 deletions

View File

@ -89,16 +89,19 @@ my %unitcodes_snd = qw( 1 0110 2 1110 3 0010 4 1010
13 0000 14 1000 15 0100 16 1100);
my %functions_set = ( "on" => 0,
"off" => 0,
"dimup" => 1,
my %functions_set = ( "on" => 0,
"off" => 0,
"dimup" => 1,
"dimdown" => 1,
"dimto" => 1,
"dimto" => 1,
"on-till" => 1,
"on-for-timer" => 1,
"on-for-timer" => 1,
"all_units_off" => 0,
"all_units_on" => 0,
"all_lights_off" => 0,
"all_lights_on" => 0,
);
my %models = (
lm12 => 'dimmer',
lm15 => 'switch',

View File

@ -2814,14 +2814,26 @@ sub Calendar_UpdateCalendar($$) {
foreach my $v (grep { $_->{type} eq "VEVENT" } @{$root->{entries}}) {
# totally skip outdated calendar entries
next if(
defined($cutoffOlderThan) &&
$v->hasKey("DTEND") &&
$v->tm($v->value("DTEND")) < $cutoff &&
!$v->hasKey("RRULE")
);
if($cutoffOlderThan) {
if(!$v->isRecurring()) {
# non recurring event
next if(
defined($cutoffOlderThan) &&
$v->hasKey("DTEND") &&
$v->tm($v->value("DTEND")) < $cutoff
);
} else {
# recurring event, inspect
my $rrule= $v->value("RRULE");
my @rrparts= split(";", $rrule);
my %r= map { split("=", $_); } @rrparts;
if(exists($r{"UNTIL"})) {
next if($v->tm($r{"UNTIL"}) < $cutoff)
}
}
}
#main::Debug "Merging " . $v->asString();
#main::Debug "Merging " . $v->asString();
my $found= 0;
my $added= 0; # flag to prevent multiple additions
$n++;
@ -3493,10 +3505,10 @@ sub CalendarEventsAsHtml($;$) {
<p>
<li><code>cutoffOlderThan &lt;timespec&gt;</code><br>
This attribute cuts off all non-recurring calendar events that ended a timespan cutoffOlderThan
This attribute cuts off all calendar events that ended a timespan cutoffOlderThan
before the last update of the calendar. The purpose of setting this attribute is to save memory.
Such calendar events cannot be accessed at all from FHEM. Calendar events are not cut off if
they are recurring or if they have no end time (DTEND).
they are recurring with no end of series (UNTIL) or if they have no end time (DTEND).
</li><p>
<li><code>onCreateEvent &lt;perl-code&gt;</code><br>
@ -3952,9 +3964,10 @@ sub CalendarEventsAsHtml($;$) {
<p>
<li><code>cutoffOlderThan &lt;timespec&gt;</code><br>
Dieses Attribut schneidet alle nicht wiederkehrenden Termine weg, die eine Zeitspanne cutoffOlderThan
Dieses Attribut schneidet alle Termine weg, die eine Zeitspanne cutoffOlderThan
vor der letzten Aktualisierung des Kalenders endeten. Der Zweck dieses Attributs ist es Speicher zu
sparen. Auf solche Termine kann gar nicht mehr aus FHEM heraus zugegriffen werden. Serientermine und
sparen. Auf solche Termine kann gar nicht mehr aus FHEM heraus zugegriffen
werden. Serientermine ohne Ende (UNTIL) und
Termine ohne Endezeitpunkt (DTEND) werden nicht weggeschnitten.
</li><p>