mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 03:14:07 +01:00
[homematic] Fix NullPointerException
in discovery (#17390)
* #17372: Fixed NPE Signed-off-by: Sönke Küper <soenkekueper@gmx.de> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
37d732d76c
commit
40bd429619
@ -78,7 +78,7 @@ public class HomematicDeviceDiscoveryService
|
|||||||
Thing bridge = thingHandler.getThing();
|
Thing bridge = thingHandler.getThing();
|
||||||
ThingStatus bridgeStatus = bridge.getStatus();
|
ThingStatus bridgeStatus = bridge.getStatus();
|
||||||
|
|
||||||
if (ThingStatus.ONLINE == bridgeStatus) {
|
if (ThingStatus.ONLINE == bridgeStatus && gateway != null) {
|
||||||
gateway.setInstallMode(true, getInstallModeDuration());
|
gateway.setInstallMode(true, getInstallModeDuration());
|
||||||
|
|
||||||
int remaining = gateway.getInstallMode();
|
int remaining = gateway.getInstallMode();
|
||||||
@ -109,7 +109,10 @@ public class HomematicDeviceDiscoveryService
|
|||||||
public synchronized void stopScan() {
|
public synchronized void stopScan() {
|
||||||
logger.debug("Stopping Homematic discovery scan");
|
logger.debug("Stopping Homematic discovery scan");
|
||||||
disableInstallMode();
|
disableInstallMode();
|
||||||
thingHandler.getGateway().cancelLoadAllDeviceMetadata();
|
final HomematicGateway gateway = thingHandler.getGateway();
|
||||||
|
if (gateway != null) {
|
||||||
|
gateway.cancelLoadAllDeviceMetadata();
|
||||||
|
}
|
||||||
waitForScanFinishing();
|
waitForScanFinishing();
|
||||||
super.stopScan();
|
super.stopScan();
|
||||||
}
|
}
|
||||||
@ -117,10 +120,11 @@ public class HomematicDeviceDiscoveryService
|
|||||||
private void disableInstallMode() {
|
private void disableInstallMode() {
|
||||||
try {
|
try {
|
||||||
synchronized (installModeSync) {
|
synchronized (installModeSync) {
|
||||||
if (isInInstallMode) {
|
final HomematicGateway gateway = thingHandler.getGateway();
|
||||||
|
if (isInInstallMode && gateway != null) {
|
||||||
isInInstallMode = false;
|
isInInstallMode = false;
|
||||||
installModeSync.notify();
|
installModeSync.notify();
|
||||||
thingHandler.getGateway().setInstallMode(false, 0);
|
gateway.setInstallMode(false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -172,10 +176,10 @@ public class HomematicDeviceDiscoveryService
|
|||||||
* Starts a thread which loads all Homematic devices connected to the gateway.
|
* Starts a thread which loads all Homematic devices connected to the gateway.
|
||||||
*/
|
*/
|
||||||
public void loadDevices() {
|
public void loadDevices() {
|
||||||
if (loadDevicesFuture == null && thingHandler.getGateway() != null) {
|
final HomematicGateway gateway = thingHandler.getGateway();
|
||||||
|
if (loadDevicesFuture == null && gateway != null) {
|
||||||
loadDevicesFuture = scheduler.submit(() -> {
|
loadDevicesFuture = scheduler.submit(() -> {
|
||||||
try {
|
try {
|
||||||
final HomematicGateway gateway = thingHandler.getGateway();
|
|
||||||
gateway.loadAllDeviceMetadata();
|
gateway.loadAllDeviceMetadata();
|
||||||
thingHandler.getTypeGenerator().validateFirmwares();
|
thingHandler.getTypeGenerator().validateFirmwares();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
@ -24,6 +24,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.openhab.binding.homematic.internal.common.HomematicConfig;
|
import org.openhab.binding.homematic.internal.common.HomematicConfig;
|
||||||
import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
|
import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
|
||||||
@ -267,8 +268,11 @@ public class HomematicBridgeHandler extends BaseBridgeHandler implements Homemat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HomematicGateway.
|
* Returns the {@link HomematicGateway}.
|
||||||
|
*
|
||||||
|
* @return The gateway or null if gateway has not yet been initialized.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public HomematicGateway getGateway() {
|
public HomematicGateway getGateway() {
|
||||||
return gateway;
|
return gateway;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user