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;
public ActivePlayerHandler(Thing thing) {
super(thing);
+ statusDrivenByLanConnectivity = false;
eventChannelUID = new ChannelUID(getThing().getUID(), SYS_INFO, BOX_EVENT);
}
@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) {
}
}
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");
}
}
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);
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;
// 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;
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);
}
}
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();
@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;
}
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;
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
@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(
# 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