diff --git a/fhem/CHANGED b/fhem/CHANGED index b4fb841ff..a14e89bfa 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 57_Calendar: added attribute cutoffOlderThan (forum #74481) - feature: fhem.pl: add -d option for debugging (Forum #74774) - bugfix: 74_AMADDevice: fix decode_utf8 call in eval - feature: 57_Calendar: reduce memory footprint (forum #74481) diff --git a/fhem/FHEM/57_Calendar.pm b/fhem/FHEM/57_Calendar.pm index 6b50aa42b..f42bdbfb9 100644 --- a/fhem/FHEM/57_Calendar.pm +++ b/fhem/FHEM/57_Calendar.pm @@ -1567,7 +1567,7 @@ sub Calendar_Initialize($) { $hash->{SetFn} = "Calendar_Set"; $hash->{AttrFn} = "Calendar_Attr"; $hash->{NotifyFn}= "Calendar_Notify"; - $hash->{AttrList}= "update:sync,async,none removevcalendar:0,1 hideOlderThan hideLaterThan onCreateEvent SSLVerify:0,1 $readingFnAttributes"; + $hash->{AttrList}= "update:sync,async,none removevcalendar:0,1 cutoffOlderThan hideOlderThan hideLaterThan onCreateEvent SSLVerify:0,1 $readingFnAttributes"; } @@ -2436,10 +2436,27 @@ sub Calendar_UpdateCalendar($$) { #main::Debug "Adding event $id with key $k to lookup hash."; } + # start of time window for cutoff + my $cutoffOlderThan = AttrVal($name, "cutoffOlderThan", undef); + my $cutoffT= 0; + my $cutoff; + if(defined($cutoffOlderThan)) { + ($error, $cutoffT)= Calendar_GetSecondsFromTimeSpec($cutoffOlderThan); + if($error) { + Log3 $hash, 2, "$name: attribute cutoffOlderThan: $error"; + }; + $cutoff= $t- $cutoffT; + } + foreach my $v (grep { $_->{type} eq "VEVENT" } @{$root->{entries}}) { # totally skip outdated calendar entries - next if ($v->tm($v->value("DTEND")) < time() && $v->valueOrDefault("RRULE", "") eq ""); + next if( + defined($cutoffOlderThan) && + $v->hasKey("DTEND") && + $v->tm($v->value("DTEND")) < $cutoff && + !$v->hasKey("RRULE") + ); #main::Debug "Merging " . $v->asString(); my $found= 0; @@ -2916,7 +2933,14 @@ sub CalendarAsHtml($;$) { DDDddays100d

- + +

  • cutoffOlderThan <timespec>
    + This attribute cuts off all non-recurring 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). +
  • +

  • onCreateEvent <perl-code>
    This attribute allows to run the Perl code <perl-code> for every @@ -3316,6 +3340,13 @@ sub CalendarAsHtml($;$) {
  • +

  • cutoffOlderThan <timespec>
    + Dieses Attribut schneidet alle nicht wiederkehrenden 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 + Termine ohne Endezeitpunkt (DTEND) werden nicht weggeschnitten. +
  • +

  • onCreateEvent <perl-code>
    Dieses Attribut führt ein Perlprogramm <perl-code> für jeden erzeugten Termin aus.