Skip to content

Commit

Permalink
[freeboxos] Fix handling of REFRESH command for connectivity channels (
Browse files Browse the repository at this point in the history
…openhab#17178)

Fix openhab#17168

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and joni1993 committed Oct 15, 2024
1 parent f82d431 commit 3b5c1c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
try {
if (checkBridgeHandler() != null) {
if (command instanceof RefreshType) {
internalPoll();
internalForcePoll();
} else if (!internalHandleCommand(channelUID.getIdWithoutGroup(), command)) {
logger.debug("Unexpected command {} on channel {}", command, channelUID.getId());
}
Expand Down Expand Up @@ -258,6 +258,10 @@ protected boolean internalHandleCommand(String channelId, Command command) throw

protected abstract void internalPoll() throws FreeboxException;

protected void internalForcePoll() throws FreeboxException {
internalPoll();
}

private void updateIfActive(String group, String channelId, State state) {
ChannelUID id = new ChannelUID(getThing().getUID(), group, channelId);
if (isLinked(id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected void internalPoll() throws FreeboxException {
pushSubscribed = getManager(WebSocketManager.class).registerListener(host.getMac(), this);
}

@Override
protected void internalForcePoll() throws FreeboxException {
LanHost host = getLanHost();
updateConnectivityChannels(host);
}

protected LanHost getLanHost() throws FreeboxException {
return getManager(LanBrowserManager.class).getHost(getMac()).map(hostIntf -> hostIntf.host())
.orElseThrow(() -> new FreeboxException("Host data not found"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ protected void internalPoll() throws FreeboxException {
}
}

@Override
protected void internalForcePoll() throws FreeboxException {
super.internalForcePoll();

logger.debug("Polling Virtual machine status");
VirtualMachine vm = getManager(VmManager.class).getDevice(getClientId());
updateVmChannels(vm);
}

public void updateVmChannels(VirtualMachine vm) {
boolean running = Status.RUNNING.equals(vm.status());
updateChannelOnOff(VM_STATUS, STATUS, running);
Expand Down

0 comments on commit 3b5c1c6

Please sign in to comment.