fix NPE in discovery (#8931)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-11-01 21:29:47 +01:00 committed by GitHub
parent 603ceedff9
commit a6f6410b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View 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;
}
}

View 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());