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($;$) {
- + +
cutoffOlderThan <timespec>
+
onCreateEvent <perl-code>
+
cutoffOlderThan <timespec>
+
onCreateEvent <perl-code>