From 4376b9db73f103e91dbc5fe9351f79036ee2baf2 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Mon, 29 Jul 2024 13:44:58 +0200 Subject: [PATCH] [freeboxos] Fix handling of REFRESH command for connectivity channels (#17178) Fix #17168 Signed-off-by: Laurent Garnier --- .../freeboxos/internal/handler/ApiConsumerHandler.java | 6 +++++- .../binding/freeboxos/internal/handler/HostHandler.java | 6 ++++++ .../binding/freeboxos/internal/handler/VmHandler.java | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java index a4052acec03..dd07a1f7dd1 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java @@ -151,7 +151,7 @@ public abstract class ApiConsumerHandler extends BaseThingHandler implements Api 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()); } @@ -258,6 +258,10 @@ public abstract class ApiConsumerHandler extends BaseThingHandler implements Api 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)) { diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java index b70c341eb99..e24fdc3303e 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java @@ -85,6 +85,12 @@ public class HostHandler extends ApiConsumerHandler { 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")); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java index 995a13e821f..b22355df203 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java @@ -51,6 +51,15 @@ public class VmHandler extends HostHandler { } } + @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);