mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[icalendar] Reload calendar file asynchronously (#9227)
* Reload calendar file asynchronously * Incorporated comments from review Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
3eda5ebbc9
commit
1a6f5b5158
@ -120,8 +120,6 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
|
||||
final ICalendarConfiguration currentConfiguration = getConfigAs(ICalendarConfiguration.class);
|
||||
configuration = currentConfiguration;
|
||||
|
||||
@ -154,14 +152,17 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
||||
}
|
||||
final long refreshTime = refreshTimeBD.longValue();
|
||||
if (calendarFile.isFile()) {
|
||||
if (reloadCalendar()) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
updateStates();
|
||||
rescheduleCalendarStateUpdate();
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||
"The calendar seems to be configured correctly, but the local copy of calendar could not be loaded.");
|
||||
}
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
|
||||
scheduler.submit(() -> {
|
||||
// reload calendar file asynchronously
|
||||
if (reloadCalendar()) {
|
||||
updateStates();
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||
"The calendar seems to be configured correctly, but the local copy of calendar could not be loaded.");
|
||||
}
|
||||
});
|
||||
pullJobFuture = scheduler.scheduleWithFixedDelay(regularPull, refreshTime, refreshTime,
|
||||
TimeUnit.MINUTES);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user