use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.
the class CBusNetworkHandler method checkNetworkOnline.
private void checkNetworkOnline() {
Network network = getNetwork();
try {
if (network != null && network.isOnline()) {
logger.debug("Network is online");
ScheduledFuture<?> initNetwork = this.initNetwork;
if (initNetwork != null) {
initNetwork.cancel(false);
this.initNetwork = null;
}
} else {
ThingStatus lastStatus = getThing().getStatus();
logger.debug("Network still not online {}", lastStatus);
}
} catch (CGateException e) {
logger.warn("Cannot check if network is online {} ", network.getNetworkID());
}
updateStatus();
}
use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.
the class CBusNetworkHandler method cgateOnline.
private void cgateOnline() {
CBusNetworkConfiguration configuration = this.configuration;
if (configuration == null) {
logger.debug("cgateOnline - NetworkHandler not initialised");
return;
}
ThingStatus lastStatus = getThing().getStatus();
logger.debug("cgateOnline {}", lastStatus);
Integer networkID = configuration.id;
String project = configuration.project;
logger.debug("cgateOnline netid {} project {}", networkID, project);
Project projectObject = getProjectObject();
Network network = getNetwork();
logger.debug("network {}", network);
CBusCGateHandler cbusCGateHandler = getCBusCGateHandler();
if (cbusCGateHandler == null) {
logger.debug("NoCGateHandler");
return;
}
try {
if (projectObject == null) {
CGateSession session = cbusCGateHandler.getCGateSession();
if (session != null) {
try {
projectObject = (Project) session.getCGateObject("//" + project);
this.projectObject = projectObject;
} catch (CGateException ignore) {
// We dont need to do anything other than stop this propagating
}
}
if (projectObject == null) {
logger.debug("Cant get projectobject");
return;
}
}
if (network == null) {
CGateSession session = cbusCGateHandler.getCGateSession();
if (session != null) {
try {
network = (Network) session.getCGateObject("//" + project + "/" + networkID);
this.network = network;
} catch (CGateException ignore) {
// We dont need to do anything other than stop this propagating
}
}
if (network == null) {
logger.debug("cgateOnline: Cant get network");
return;
}
}
String state = network.getState();
logger.debug("Network state is {}", state);
if ("new".equals(state)) {
projectObject.start();
logger.debug("Need to wait for it to be synced");
} else if ("sync".equals(state)) {
logger.debug("Network is syncing so wait for it to be ok");
}
if (!"ok".equals(state)) {
ScheduledFuture<?> initNetwork = this.initNetwork;
if (initNetwork == null || initNetwork.isCancelled()) {
this.initNetwork = scheduler.scheduleWithFixedDelay(this::checkNetworkOnline, 30, 30, TimeUnit.SECONDS);
logger.debug("Schedule a check every minute");
} else {
logger.debug("initNetwork alreadys started");
}
updateStatus();
return;
}
} catch (CGateException e) {
logger.warn("Cannot load C-Bus network {}", networkID, e);
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.COMMUNICATION_ERROR);
}
updateStatus();
}
use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.
the class CBusCGateHandler method updateStatus.
private void updateStatus() {
ThingStatus lastStatus = getThing().getStatus();
CGateSession cGateSession = this.cGateSession;
if (cGateSession == null) {
return;
}
if (cGateSession.isConnected()) {
updateStatus(ThingStatus.ONLINE);
} else {
if (lastStatus != ThingStatus.OFFLINE) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
}
}
if (!getThing().getStatus().equals(lastStatus)) {
boolean isOnline = getThing().getStatus().equals(ThingStatus.ONLINE);
updateChildThings(isOnline);
}
}
use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.
the class EvohomeAccountBridgeHandler method updateThings.
private void updateThings() {
Map<String, TemperatureControlSystemStatus> idToTcsMap = new HashMap<>();
Map<String, ZoneStatus> idToZoneMap = new HashMap<>();
Map<String, GatewayStatus> tcsIdToGatewayMap = new HashMap<>();
Map<String, String> zoneIdToTcsIdMap = new HashMap<>();
Map<String, ThingStatus> idToTcsThingsStatusMap = new HashMap<>();
// First, create a lookup table
for (LocationStatus location : apiClient.getInstallationStatus()) {
for (GatewayStatus gateway : location.getGateways()) {
for (TemperatureControlSystemStatus tcs : gateway.getTemperatureControlSystems()) {
idToTcsMap.put(tcs.getSystemId(), tcs);
tcsIdToGatewayMap.put(tcs.getSystemId(), gateway);
for (ZoneStatus zone : tcs.getZones()) {
idToZoneMap.put(zone.getZoneId(), zone);
zoneIdToTcsIdMap.put(zone.getZoneId(), tcs.getSystemId());
}
}
}
}
// Then update the things by type, with pre-filtered info
for (Thing handler : getThing().getThings()) {
ThingHandler thingHandler = handler.getHandler();
if (thingHandler instanceof EvohomeTemperatureControlSystemHandler) {
EvohomeTemperatureControlSystemHandler tcsHandler = (EvohomeTemperatureControlSystemHandler) thingHandler;
tcsHandler.update(tcsIdToGatewayMap.get(tcsHandler.getId()), idToTcsMap.get(tcsHandler.getId()));
idToTcsThingsStatusMap.put(tcsHandler.getId(), tcsHandler.getThing().getStatus());
}
if (thingHandler instanceof EvohomeHeatingZoneHandler) {
EvohomeHeatingZoneHandler zoneHandler = (EvohomeHeatingZoneHandler) thingHandler;
zoneHandler.update(idToTcsThingsStatusMap.get(zoneIdToTcsIdMap.get(zoneHandler.getId())), idToZoneMap.get(zoneHandler.getId()));
}
}
}
use of org.openhab.core.thing.ThingStatus in project openhab-addons by openhab.
the class DarkSkyAPIHandler method determineBridgeStatus.
private void determineBridgeStatus() {
ThingStatus status = ThingStatus.OFFLINE;
for (Thing thing : getThing().getThings()) {
if (ThingStatus.ONLINE.equals(thing.getStatus())) {
status = ThingStatus.ONLINE;
break;
}
}
updateStatus(status);
}
Aggregations