mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
[hue] Fix channel refresh (API v2) (#15736)
* Fix refresh/initial state request Fixes #15735 * Fix channel updates when thing comes online Fixes #15669 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Also-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
31101685fc
commit
4b0c551065
@ -300,19 +300,8 @@ public class Clip2ThingHandler extends BaseThingHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command commandParam) {
|
public void handleCommand(ChannelUID channelUID, Command commandParam) {
|
||||||
if (RefreshType.REFRESH.equals(commandParam)) {
|
if (RefreshType.REFRESH.equals(commandParam)) {
|
||||||
if ((thing.getStatus() == ThingStatus.ONLINE) && updateDependenciesDone) {
|
if (thing.getStatus() == ThingStatus.ONLINE) {
|
||||||
Future<?> task = updateServiceContributorsTask;
|
refreshAllChannels();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -524,6 +513,21 @@ public class Clip2ThingHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Apply device specific work-arounds needed for given command.
|
||||||
*
|
*
|
||||||
@ -899,11 +903,7 @@ public class Clip2ThingHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
} else if (thing.getStatus() != ThingStatus.ONLINE) {
|
} else if (thing.getStatus() != ThingStatus.ONLINE) {
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
// issue REFRESH command to update all channels
|
refreshAllChannels();
|
||||||
Channel lastUpdateChannel = thing.getChannel(CHANNEL_2_LAST_UPDATED);
|
|
||||||
if (Objects.nonNull(lastUpdateChannel)) {
|
|
||||||
handleCommand(lastUpdateChannel.getUID(), RefreshType.REFRESH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user