Java Code Examples for org.eclipse.smarthome.core.thing.ThingStatus#OFFLINE
The following examples show how to use
org.eclipse.smarthome.core.thing.ThingStatus#OFFLINE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MagicBridgedThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void initialize() { Bridge bridge = getBridge(); if (bridge == null || bridge.getStatus() == ThingStatus.UNINITIALIZED) { updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.BRIDGE_UNINITIALIZED); } else if (bridge.getStatus() == ThingStatus.OFFLINE) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); } else if (bridge.getStatus() == ThingStatus.ONLINE) { updateStatus(ThingStatus.ONLINE); } else { updateStatus(ThingStatus.UNKNOWN); } }
Example 2
Source File: MagicDelayedOnlineHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void handleCommand(ChannelUID channelUID, Command command) { if (channelUID.getId().equals("number")) { if (command instanceof DecimalType) { DecimalType cmd = (DecimalType) command; int cmdInt = cmd.intValue(); ThingStatus status = cmdInt > 0 ? ThingStatus.ONLINE : ThingStatus.OFFLINE; int waitTime = Math.abs(cmd.intValue()); scheduler.schedule(() -> updateStatus(status), waitTime, TimeUnit.SECONDS); } } }
Example 3
Source File: BaseThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE && getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.BRIDGE_OFFLINE) { updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE); } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); } }
Example 4
Source File: OpenWeatherMapAPIHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private void determineBridgeStatus() { ThingStatus status = ThingStatus.OFFLINE; for (Thing thing : getThing().getThings()) { if (ThingStatus.ONLINE.equals(thing.getStatus())) { status = ThingStatus.ONLINE; break; } } updateStatus(status); }
Example 5
Source File: OpenWeatherMapAPIHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private void updateThings() { ThingStatus status = ThingStatus.OFFLINE; for (Thing thing : getThing().getThings()) { if (ThingStatus.ONLINE.equals(updateThing((AbstractOpenWeatherMapHandler) thing.getHandler(), thing))) { status = ThingStatus.ONLINE; } } updateStatus(status); }
Example 6
Source File: OpenWeatherMapAPIHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private ThingStatus updateThing(@Nullable AbstractOpenWeatherMapHandler handler, Thing thing) { if (handler != null && connection != null) { handler.updateData(connection); return thing.getStatus(); } else { logger.debug("Cannot update weather data of thing '{}' as location handler is null.", thing.getUID()); return ThingStatus.OFFLINE; } }
Example 7
Source File: HomematicBridgeHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void onStateUpdated(HmDatapoint dp) { Thing hmThing = getThingByUID(UidUtils.generateThingUID(dp.getChannel().getDevice(), getThing())); if (hmThing != null) { final ThingStatus status = hmThing.getStatus(); if (status == ThingStatus.ONLINE || status == ThingStatus.OFFLINE) { HomematicThingHandler thingHandler = (HomematicThingHandler) hmThing.getHandler(); if (thingHandler != null) { thingHandler.updateDatapointState(dp); } } } }
Example 8
Source File: HomematicThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
/** * Updates the thing status based on device status. */ private void updateStatus(HmDevice device) throws GatewayNotAvailableException, IOException { loadHomematicChannelValues(device.getChannel(0)); ThingStatus oldStatus = thing.getStatus(); ThingStatus newStatus = ThingStatus.ONLINE; ThingStatusDetail newDetail = ThingStatusDetail.NONE; if (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(); } }
Example 9
Source File: AbstractMQTTThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
/** * Return the bridge status. */ public ThingStatusInfo getBridgeStatus() { Bridge b = getBridge(); if (b != null) { return b.getStatusInfo(); } else { return new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, null); } }
Example 10
Source File: OwBaseThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE && getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.BRIDGE_OFFLINE) { if (validConfig) { updatePresenceStatus(UnDefType.UNDEF); } else { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR); } } else if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); } }
Example 11
Source File: TradfriThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void setStatus(ThingStatus status, ThingStatusDetail statusDetail) { if (active && getBridge().getStatus() != ThingStatus.OFFLINE && status != ThingStatus.ONLINE) { updateStatus(status, statusDetail); // we are offline and lost our observe relation - let's try to establish the connection in 10 seconds again scheduler.schedule(() -> { if (observeRelation != null) { observeRelation.reactiveCancel(); observeRelation = null; } observeRelation = coapClient.startObserve(this); }, 10, TimeUnit.SECONDS); } }
Example 12
Source File: TradfriThingHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { super.bridgeStatusChanged(bridgeStatusInfo); // the status might have changed because the bridge is completely reconfigured - so we need to re-establish // our CoAP connection as well if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { dispose(); } else if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) { initialize(); } }
Example 13
Source File: LifxLightHandler.java From smarthome with Eclipse Public License 2.0 | 4 votes |
public boolean isOffline() { return thing.getStatus() == ThingStatus.OFFLINE; }
Example 14
Source File: SonyAudioHandler.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Override public void initialize() { Configuration config = getThing().getConfiguration(); String ipAddress = (String) config.get(SonyAudioBindingConstants.HOST_PARAMETER); String path = (String) config.get(SonyAudioBindingConstants.SCALAR_PATH_PARAMETER); Object port_o = config.get(SonyAudioBindingConstants.SCALAR_PORT_PARAMETER); int port = 10000; if (port_o instanceof BigDecimal) { port = ((BigDecimal) port_o).intValue(); } else if (port_o instanceof Integer) { port = (int) port_o; } Object refresh_o = config.get(SonyAudioBindingConstants.REFRESHINTERVAL); int refresh = 0; if (refresh_o instanceof BigDecimal) { refresh = ((BigDecimal) refresh_o).intValue(); } else if (refresh_o instanceof Integer) { refresh = (int) refresh_o; } try { connection = new SonyAudioConnection(ipAddress, port, path, this, scheduler, webSocketClient); Runnable connectionChecker = () -> { try { if (!connection.checkConnection()) { if (getThing().getStatus() != ThingStatus.OFFLINE) { logger.debug("Lost connection"); updateStatus(ThingStatus.OFFLINE); } } } catch (Exception ex) { logger.warn("Exception in check connection to @{}. Cause: {}", connection.getConnectionName(), ex.getMessage(), ex); } }; connectionCheckerFuture = scheduler.scheduleWithFixedDelay(connectionChecker, 1, 10, TimeUnit.SECONDS); // Start the status updater startAutomaticRefresh(refresh); } catch (URISyntaxException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage()); } }
Example 15
Source File: ThingHandlerHelper.java From smarthome with Eclipse Public License 2.0 | 2 votes |
/** * Checks if the given state indicates that a thing handler has been initialized. * * @return true if the thing handler has been initialized, otherwise false. */ public static boolean isHandlerInitialized(final ThingStatus thingStatus) { return thingStatus == ThingStatus.OFFLINE || thingStatus == ThingStatus.ONLINE || thingStatus == ThingStatus.UNKNOWN; }