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());
}
}
}
}
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);
}
}
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);
}
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);
}
}
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();
}
}
Aggregations