Search in sources :

Example 11 with ThingStatus

use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.

the class BlindHandler method initialize.

@Override
public void initialize() {
    this.id = getConfig().as(BlindConfig.class).id;
    Bridge bridge = getBridge();
    if (bridge != null) {
        dominoswissHandler = (EGateHandler) bridge.getHandler();
        EGateHandler localDominoswissHandler = dominoswissHandler;
        if (localDominoswissHandler != null) {
            localDominoswissHandler.registerBlind(this.id, getThing().getUID());
            try {
                ThingStatus bridgeStatus = bridge.getStatus();
                if (bridgeStatus == ThingStatus.ONLINE && getThing().getStatus() != ThingStatus.ONLINE) {
                    updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
                    localDominoswissHandler = (EGateHandler) bridge.getHandler();
                } else if (bridgeStatus == ThingStatus.OFFLINE) {
                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
                }
            } catch (Exception e) {
                logger.debug("Could not update ThingStatus ", e);
                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, e.toString());
            }
        }
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) Bridge(org.openhab.core.thing.Bridge)

Example 12 with ThingStatus

use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.

the class HarmonyDeviceHandler method updateBridgeStatus.

/**
 * Updates our state based on the bridge/hub
 */
private void updateBridgeStatus() {
    Bridge bridge = getBridge();
    ThingStatus bridgeStatus = bridge != null ? bridge.getStatus() : null;
    HarmonyHubHandler hubHandler = getHarmonyHubHandler();
    boolean bridgeOnline = bridgeStatus == ThingStatus.ONLINE;
    boolean thingOnline = getThing().getStatus() == ThingStatus.ONLINE;
    if (bridgeOnline && hubHandler != null && !thingOnline) {
        updateStatus(ThingStatus.ONLINE);
        hubHandler.getConfigFuture().thenAcceptAsync(this::updateButtonPressChannel, scheduler).exceptionally(e -> {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Getting config failed: " + e.getMessage());
            return null;
        });
    } else if (!bridgeOnline || hubHandler == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) Bridge(org.openhab.core.thing.Bridge)

Example 13 with ThingStatus

use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.

the class EnturNoHandler method updateThing.

private void updateThing() {
    ThingStatus status = ThingStatus.OFFLINE;
    if (connection != null) {
        logger.trace("Updating data");
        updateData(connection);
        status = thing.getStatus();
    } else {
        logger.debug("Cannot update real-time data of thing '{}' as connection is null.", thing.getUID());
        status = ThingStatus.OFFLINE;
    }
    updateStatus(status);
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus)

Example 14 with ThingStatus

use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.

the class HomematicDeviceDiscoveryService method enableInstallMode.

/**
 * Will set controller in <i>installMode==true</i>, but only if the bridge
 * is ONLINE (e.g. not during INITIALIZATION).
 */
private void enableInstallMode() {
    try {
        HomematicGateway gateway = bridgeHandler.getGateway();
        ThingStatus bridgeStatus = null;
        if (bridgeHandler != null) {
            Thing bridge = bridgeHandler.getThing();
            bridgeStatus = bridge.getStatus();
        }
        if (ThingStatus.ONLINE == bridgeStatus) {
            gateway.setInstallMode(true, getInstallModeDuration());
            int remaining = gateway.getInstallMode();
            if (remaining > 0) {
                setIsInInstallMode();
                logger.debug("Successfully put controller in install mode. Remaining time: {} seconds", remaining);
            } else {
                logger.warn("Controller did not accept requested install mode");
            }
        } else {
            logger.debug("Will not attempt to set controller in install mode, because bridge is not ONLINE.");
        }
    } catch (Exception ex) {
        logger.warn("Failed to set Homematic controller in install mode", ex);
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) HomematicGateway(org.openhab.binding.homematic.internal.communicator.HomematicGateway) Thing(org.openhab.core.thing.Thing) ExecutionException(java.util.concurrent.ExecutionException)

Example 15 with ThingStatus

use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.

the class HomematicThingHandler method updateStatus.

/**
 * Updates the thing status based on device status.
 */
private void updateStatus(HmDevice device) throws GatewayNotAvailableException, IOException {
    loadHomematicChannelValues(device.getChannel(0));
    ThingStatus oldStatus = thing.getStatus();
    if (oldStatus == ThingStatus.UNINITIALIZED) {
        return;
    }
    ThingStatus newStatus = ThingStatus.ONLINE;
    ThingStatusDetail newDetail = ThingStatusDetail.NONE;
    if ((getBridge() != null) && (getBridge().getStatus() == ThingStatus.OFFLINE)) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.BRIDGE_OFFLINE;
    } else if (device.isFirmwareUpdating()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.FIRMWARE_UPDATING;
    } else if (device.isUnreach()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.COMMUNICATION_ERROR;
    } else if (device.isConfigPending() || device.isUpdatePending()) {
        newDetail = ThingStatusDetail.CONFIGURATION_PENDING;
    }
    if (thing.getStatus() != newStatus || thing.getStatusInfo().getStatusDetail() != newDetail) {
        updateStatus(newStatus, newDetail);
    }
    if (oldStatus == ThingStatus.OFFLINE && newStatus == ThingStatus.ONLINE) {
        initialize();
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) ThingStatusDetail(org.openhab.core.thing.ThingStatusDetail)

Aggregations

ThingStatus (org.openhab.core.thing.ThingStatus)62 ThingStatusDetail (org.openhab.core.thing.ThingStatusDetail)14 Thing (org.openhab.core.thing.Thing)12 Bridge (org.openhab.core.thing.Bridge)10 State (org.openhab.core.types.State)9 HashMap (java.util.HashMap)6 ThingHandler (org.openhab.core.thing.binding.ThingHandler)6 IOException (java.io.IOException)5 Nullable (org.eclipse.jdt.annotation.Nullable)4 AbstractRioHandlerCallback (org.openhab.binding.russound.internal.rio.AbstractRioHandlerCallback)4 StatefulHandlerCallback (org.openhab.binding.russound.internal.rio.StatefulHandlerCallback)4 ShellyDeviceProfile (org.openhab.binding.shelly.internal.api.ShellyDeviceProfile)4 CGateException (com.daveoxley.cbus.CGateException)3 Network (com.daveoxley.cbus.Network)3 TreeMap (java.util.TreeMap)3 SocketSession (org.openhab.binding.russound.internal.net.SocketSession)3 ThingStatusInfo (org.openhab.core.thing.ThingStatusInfo)3 CGateSession (com.daveoxley.cbus.CGateSession)2 Map (java.util.Map)2 CBusNetworkConfiguration (org.openhab.binding.cbus.internal.CBusNetworkConfiguration)2