]> git.basschouten.com Git - openhab-addons.git/commitdiff
fix NPE in discovery (#8931)
authorJ-N-K <J-N-K@users.noreply.github.com>
Sun, 1 Nov 2020 20:29:47 +0000 (21:29 +0100)
committerGitHub <noreply@github.com>
Sun, 1 Nov 2020 20:29:47 +0000 (21:29 +0100)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.neato/src/main/java/org/openhab/binding/neato/internal/classes/Robot.java
bundles/org.openhab.binding.neato/src/main/java/org/openhab/binding/neato/internal/discovery/NeatoAccountDiscoveryService.java

index 7cc4670bbcc87753772af227b084d9269e8eddc7..707fd5dfab040c2fa1ade72435e50756711adbf0 100644 (file)
@@ -148,4 +148,8 @@ public class Robot {
     public void setCreatedAt(String createdAt) {
         this.createdAt = createdAt;
     }
+
+    public boolean discoveryInformationPresent() {
+        return serial != null && secretKey != null && name != null && model != null;
+    }
 }
index 70bc6f531c146df7ea077776324c923531d0af0c..050fd8d3c094ee0aa507306acae438fffb2ab1fb 100644 (file)
@@ -84,9 +84,14 @@ public class NeatoAccountDiscoveryService extends AbstractDiscoveryService {
     }
 
     private void addThing(Robot robot) {
+        if (robot == null || !robot.discoveryInformationPresent()) {
+            return;
+        }
+
         logger.debug("addThing(): Adding new Neato unit {} to the smarthome inbox", robot.getName());
 
         Map<String, Object> properties = new HashMap<>();
+        String serial = robot.getSerial();
         ThingUID thingUID = new ThingUID(NeatoBindingConstants.THING_TYPE_VACUUMCLEANER, bridgeUID, robot.getSerial());
         properties.put(NeatoBindingConstants.CONFIG_SECRET, robot.getSecretKey());
         properties.put(NeatoBindingConstants.CONFIG_SERIAL, robot.getSerial());