@Override
public void handleCommand(ChannelUID channelUID, Command commandParam) {
if (RefreshType.REFRESH.equals(commandParam)) {
- if ((thing.getStatus() == ThingStatus.ONLINE) && updateDependenciesDone) {
- Future<?> task = updateServiceContributorsTask;
- if (Objects.isNull(task) || !task.isDone()) {
- cancelTask(updateServiceContributorsTask, false);
- updateServiceContributorsTask = scheduler.schedule(() -> {
- try {
- updateServiceContributors();
- } catch (ApiException | AssetNotLoadedException e) {
- logger.debug("{} -> handleCommand() error {}", resourceId, e.getMessage(), e);
- } catch (InterruptedException e) {
- }
- }, 3, TimeUnit.SECONDS);
- }
+ if (thing.getStatus() == ThingStatus.ONLINE) {
+ refreshAllChannels();
}
return;
}
}
}
+ private void refreshAllChannels() {
+ if (!updateDependenciesDone) {
+ return;
+ }
+ cancelTask(updateServiceContributorsTask, false);
+ updateServiceContributorsTask = scheduler.schedule(() -> {
+ try {
+ updateServiceContributors();
+ } catch (ApiException | AssetNotLoadedException e) {
+ logger.debug("{} -> handleCommand() error {}", resourceId, e.getMessage(), e);
+ } catch (InterruptedException e) {
+ }
+ }, 3, TimeUnit.SECONDS);
+ }
+
/**
* Apply device specific work-arounds needed for given command.
*
}
} else if (thing.getStatus() != ThingStatus.ONLINE) {
updateStatus(ThingStatus.ONLINE);
- // issue REFRESH command to update all channels
- Channel lastUpdateChannel = thing.getChannel(CHANNEL_2_LAST_UPDATED);
- if (Objects.nonNull(lastUpdateChannel)) {
- handleCommand(lastUpdateChannel.getUID(), RefreshType.REFRESH);
- }
+ refreshAllChannels();
}
}
}