mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-24 02:59:22 +00:00
57_Calendar: added attribute cutoffOlderThan (forum #74481)
git-svn-id: https://svn.fhem.de/fhem/trunk@14832 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2044754cfa
commit
201cab2609
@ -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)
|
||||
|
@ -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($;$) {
|
||||
<tr><td>DDDd</td><td>days</td><td>100d</td></tr>
|
||||
</table></li>
|
||||
<p>
|
||||
|
||||
|
||||
<li><code>cutoffOlderThan <timespec></code><br>
|
||||
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).
|
||||
</li><p>
|
||||
|
||||
<li><code>onCreateEvent <perl-code></code><br>
|
||||
|
||||
This attribute allows to run the Perl code <perl-code> for every
|
||||
@ -3316,6 +3340,13 @@ sub CalendarAsHtml($;$) {
|
||||
</table></li>
|
||||
<p>
|
||||
|
||||
<li><code>cutoffOlderThan <timespec></code><br>
|
||||
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.
|
||||
</li><p>
|
||||
|
||||
<li><code>onCreateEvent <perl-code></code><br>
|
||||
|
||||
Dieses Attribut führt ein Perlprogramm <perl-code> für jeden erzeugten Termin aus.
|
||||
|
Loading…
x
Reference in New Issue
Block a user