From 28b12765f22f6fb4fc1ed401012c66fd0ce2111c Mon Sep 17 00:00:00 2001 From: borisneubert Date: Fri, 28 Sep 2018 19:18:37 +0000 Subject: [PATCH] 57_Calendar: cutoffOlderThan also removes recurring events when the series has ended. git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@17421 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/20_X10.pm | 15 +++++++++------ FHEM/57_Calendar.pm | 35 ++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/FHEM/20_X10.pm b/FHEM/20_X10.pm index 9e8ac013b..9ddc5d9fc 100755 --- a/FHEM/20_X10.pm +++ b/FHEM/20_X10.pm @@ -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', diff --git a/FHEM/57_Calendar.pm b/FHEM/57_Calendar.pm index eada0d0c1..9d78e2d9d 100644 --- a/FHEM/57_Calendar.pm +++ b/FHEM/57_Calendar.pm @@ -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($;$) {

  • cutoffOlderThan <timespec>
    - 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).
  • onCreateEvent <perl-code>
    @@ -3952,9 +3964,10 @@ sub CalendarEventsAsHtml($;$) {

  • cutoffOlderThan <timespec>
    - 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.