diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java index 3bbd2f2e21405..e47f0d6d47e95 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java @@ -30,6 +30,7 @@ import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.binding.ThingHandlerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,6 +51,7 @@ public class ActivePlayerHandler extends PlayerHandler implements FreeDeviceIntf public ActivePlayerHandler(Thing thing) { super(thing); + statusDrivenByLanConnectivity = false; eventChannelUID = new ChannelUID(getThing().getUID(), SYS_INFO, BOX_EVENT); } @@ -69,9 +71,24 @@ void initializeProperties(Map properties) throws FreeboxExceptio @Override protected void internalPoll() throws FreeboxException { super.internalPoll(); - if (thing.getStatus().equals(ThingStatus.ONLINE)) { + poll(); + } + + @Override + protected void internalForcePoll() throws FreeboxException { + super.internalForcePoll(); + poll(); + } + + private void poll() throws FreeboxException { + if (reachable) { Player player = getManager(PlayerManager.class).getDevice(getClientId()); - updateStatus(player.reachable() ? ThingStatus.ONLINE : ThingStatus.OFFLINE); + logger.debug("{}: poll with player.reachable() = {}", thing.getUID(), player.reachable()); + if (player.reachable()) { + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/info-player-not-reachable"); + } if (player.reachable()) { Status status = getManager(PlayerManager.class).getPlayerStatus(getClientId()); if (status != null) { @@ -89,6 +106,9 @@ protected void internalPoll() throws FreeboxException { } } updateChannelQuantity(SYS_INFO, UPTIME, uptime, Units.SECOND); + } else { + logger.debug("{}: poll with reachable={}", thing.getUID(), reachable); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/info-player-not-reachable"); } } 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 8a9ad3713f406..aa1b5dae03133 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 @@ -218,7 +218,7 @@ private void startRefreshJob() { ThingStatusDetail detail = thing.getStatusInfo().getStatusDetail(); if (ThingStatusDetail.DUTY_CYCLE.equals(detail)) { try { - internalPoll(); + internalForcePoll(); } catch (FreeboxException ignore) { // An exception is normal if the box is rebooting then let's try again later... addJob("Initialize", this::initialize, 10, TimeUnit.SECONDS); 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 eacac76df48db..4a238d001e1e5 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 @@ -28,6 +28,7 @@ import org.openhab.binding.freeboxos.internal.config.ApiConsumerConfiguration; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.binding.ThingHandlerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +47,8 @@ public class HostHandler extends ApiConsumerHandler { // We start in pull mode and switch to push after a first update... protected boolean pushSubscribed = false; + protected boolean statusDrivenByLanConnectivity = true; + protected boolean reachable; private int tryConfigureMediaSink = 1; @@ -93,7 +96,8 @@ protected void internalPoll() throws FreeboxException { LanHost host = getLanHost(); updateConnectivityChannels(host); - logger.debug("Switching to push mode - refreshInterval will now be ignored for Connectivity data"); + logger.debug("{}: switching to push mode - refreshInterval will now be ignored for Connectivity data", + thing.getUID()); pushSubscribed = getManager(WebSocketManager.class).registerListener(host.getMac(), this); } @@ -114,10 +118,17 @@ protected LanHost getLanHost() throws FreeboxException { } public void updateConnectivityChannels(LanHost host) { + logger.debug("{}: updateConnectivityChannels with host.reachable() = {}", thing.getUID(), host.reachable()); updateChannelOnOff(CONNECTIVITY, REACHABLE, host.reachable()); updateChannelDateTimeState(CONNECTIVITY, LAST_SEEN, host.getLastSeen()); updateChannelString(CONNECTIVITY, IP_ADDRESS, host.getIpv4()); - updateStatus(host.reachable() ? ThingStatus.ONLINE : ThingStatus.OFFLINE); + if (statusDrivenByLanConnectivity) { + if (host.reachable()) { + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/info-host-not-reachable"); + } + } // We will check and configure audio sink only when the host reachability changed if (reachable != host.reachable()) { reachable = host.reachable(); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java index 8cb9ed5d4d586..eaa62f9929005 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java @@ -66,7 +66,16 @@ void initializeProperties(Map properties) throws FreeboxExceptio @Override protected void internalPoll() throws FreeboxException { super.internalPoll(); + poll(); + } + + @Override + protected void internalForcePoll() throws FreeboxException { + super.internalForcePoll(); + poll(); + } + private void poll() throws FreeboxException { if (!thing.getStatus().equals(ThingStatus.ONLINE)) { return; } 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 9a0917cadf7a2..ef33694b22b97 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 @@ -24,6 +24,7 @@ import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.types.Command; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +76,11 @@ public void updateVmChannels(VirtualMachine vm) { boolean running = Status.RUNNING.equals(vm.status()); updateChannelOnOff(VM_STATUS, STATUS, running); updateChannelOnOff(CONNECTIVITY, REACHABLE, running); - updateStatus(running ? ThingStatus.ONLINE : ThingStatus.OFFLINE); + if (running) { + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/info-vm-not-running"); + } } @Override diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/WifiStationHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/WifiStationHandler.java index 47bf88c97ee6f..a37e5f88a7499 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/WifiStationHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/WifiStationHandler.java @@ -57,7 +57,16 @@ public WifiStationHandler(Thing thing) { @Override protected void internalPoll() throws FreeboxException { super.internalPoll(); + poll(); + } + + @Override + protected void internalForcePoll() throws FreeboxException { + super.internalForcePoll(); + poll(); + } + private void poll() throws FreeboxException { MACAddress mac = getMac(); if (mac == null) { throw new FreeboxException( diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties index c1d7139d8ddc6..c03e3084de8b1 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties @@ -355,6 +355,9 @@ channel-type.freeboxos.wifi-status.description = Indicates whether the wifi netw # messages info-conf-pending = Please accept pairing request directly on your freebox +info-host-not-reachable = Host is not reachable +info-player-not-reachable = Player is not reachable +info-vm-not-running = VM is not running # iconprovider