last_update describes the last successful update of the calendar. Fixes #9301.
Signed-off-by: Michael Wodniok <michi@noorganization.org>
| next_title | String | Title of the next event |
| next_start | DateTime | Start of the next event |
| next_end | DateTime | End of the next event |
+| last_update | DateTime | The time and date of the last successful update of the calendar |
### Channels for `eventfilter`
public static final String CHANNEL_NEXT_EVENT_TITLE = "next_title";
public static final String CHANNEL_NEXT_EVENT_START = "next_start";
public static final String CHANNEL_NEXT_EVENT_END = "next_end";
+ public static final String CHANNEL_LAST_UPDATE = "last_update";
// additional constants
public static final int HTTP_TIMEOUT_SECS = 60;
private @Nullable AbstractPresentableCalendar runtimeCalendar;
private @Nullable ScheduledFuture<?> updateJobFuture;
private Instant updateStatesLastCalledTime;
+ private @Nullable Instant calendarDownloadedTime;
public ICalendarHandler(Bridge bridge, HttpClient httpClient, EventPublisher eventPublisher,
TimeZoneProvider tzProvider) {
final AbstractPresentableCalendar calendar = AbstractPresentableCalendar.create(fileStream);
runtimeCalendar = calendar;
rescheduleCalendarStateUpdate();
+ calendarDownloadedTime = Instant.ofEpochMilli(calendarFile.lastModified());
} catch (IOException | CalendarException e) {
logger.warn("Loading calendar failed: {}", e.getMessage());
return false;
updateState(CHANNEL_NEXT_EVENT_END, UnDefType.UNDEF);
}
+ final Instant lastUpdate = calendarDownloadedTime;
+ updateState(CHANNEL_LAST_UPDATE,
+ (lastUpdate != null ? new DateTimeType(lastUpdate.atZone(tzProvider.getTimeZone()))
+ : UnDefType.UNDEF));
+
// process all Command Tags in all Calendar Events which ENDED since updateStates was last called
// the END Event tags must be processed before the BEGIN ones
executeEventCommands(calendar.getJustEndedEvents(updateStatesLastCalledTime, now), CommandTagType.END);
channel-type.icalendar.event_next_start.description = Start des nächsten Eintrags
channel-type.icalendar.event_next_end.label = Ende des nächsten Eintrags
channel-type.icalendar.event_next_end.description = Ende des nächsten Eintrags
+channel-type.icalendar.last_update.label = Letztes Kalender-Update
+channel-type.icalendar.last_update.description = Datum und Zeit des letzten erfolgreichen Kalender-Downloads
channel-group-type.icalendar.result.label = Ergebnis
channel-group-type.icalendar.result.description = Ergebnis, gefunden durch den Filter
channel-type.icalendar.result_start.label = Ergebnisstart
<channel id="next_title" typeId="event_next_title"/>
<channel id="next_start" typeId="event_next_start"/>
<channel id="next_end" typeId="event_next_end"/>
+ <channel id="last_update" typeId="last_update"/>
</channels>
<config-description>
<description>Title of the found result in calendar</description>
<state readOnly="true"/>
</channel-type>
+ <channel-type id="last_update">
+ <item-type>DateTime</item-type>
+ <label>Last Update</label>
+ <description>The time the calendar was updated successfully last time</description>
+ <state readOnly="true"/>
+ </channel-type>
<channel-group-type id="result">
<label>Result Event</label>
<description>A resulting event found by filter</description>