Thing bridge = thingHandler.getThing();
ThingStatus bridgeStatus = bridge.getStatus();
- if (ThingStatus.ONLINE == bridgeStatus) {
+ if (ThingStatus.ONLINE == bridgeStatus && gateway != null) {
gateway.setInstallMode(true, getInstallModeDuration());
int remaining = gateway.getInstallMode();
public synchronized void stopScan() {
logger.debug("Stopping Homematic discovery scan");
disableInstallMode();
- thingHandler.getGateway().cancelLoadAllDeviceMetadata();
+ final HomematicGateway gateway = thingHandler.getGateway();
+ if (gateway != null) {
+ gateway.cancelLoadAllDeviceMetadata();
+ }
waitForScanFinishing();
super.stopScan();
}
private void disableInstallMode() {
try {
synchronized (installModeSync) {
- if (isInInstallMode) {
+ final HomematicGateway gateway = thingHandler.getGateway();
+ if (isInInstallMode && gateway != null) {
isInInstallMode = false;
installModeSync.notify();
- thingHandler.getGateway().setInstallMode(false, 0);
+ gateway.setInstallMode(false, 0);
}
}
} catch (Exception ex) {
* Starts a thread which loads all Homematic devices connected to the gateway.
*/
public void loadDevices() {
- if (loadDevicesFuture == null && thingHandler.getGateway() != null) {
+ final HomematicGateway gateway = thingHandler.getGateway();
+ if (loadDevicesFuture == null && gateway != null) {
loadDevicesFuture = scheduler.submit(() -> {
try {
- final HomematicGateway gateway = thingHandler.getGateway();
gateway.loadAllDeviceMetadata();
thingHandler.getTypeGenerator().validateFirmwares();
} catch (Throwable ex) {
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.homematic.internal.common.HomematicConfig;
import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
}
/**
- * Returns the HomematicGateway.
+ * Returns the {@link HomematicGateway}.
+ *
+ * @return The gateway or null if gateway has not yet been initialized.
*/
+ @Nullable
public HomematicGateway getGateway() {
return gateway;
}