[deconz] fix gateway discovery (#9362)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-12-13 16:18:38 +01:00 committed by GitHub
parent ac074ea1f0
commit c541776f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -14,6 +14,7 @@ package org.openhab.binding.deconz.internal.discovery;
import static org.openhab.binding.deconz.internal.BindingConstants.*;
import java.net.URI;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
@ -23,6 +24,7 @@ import java.util.TreeMap;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.jupnp.model.meta.DeviceDetails;
import org.jupnp.model.meta.ManufacturerDetails;
import org.jupnp.model.meta.RemoteDevice;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
@ -67,7 +69,7 @@ public class BridgeDiscoveryParticipant implements UpnpDiscoveryParticipant {
// Add host+port
String host = descriptorURL.getHost();
int port = descriptorURL.getPort();
name = name + " (" + host + ":" + String.valueOf(port) + ")";
name = name + " (" + host + ":" + port + ")";
Map<String, Object> properties = new TreeMap<>();
@ -82,9 +84,15 @@ public class BridgeDiscoveryParticipant implements UpnpDiscoveryParticipant {
@Override
public @Nullable ThingUID getThingUID(RemoteDevice device) {
DeviceDetails details = device.getDetails();
if (details != null && details.getManufacturerDetails() != null
&& "dresden elektronik".equals(details.getManufacturerDetails().getManufacturer())) {
return new ThingUID(BRIDGE_TYPE, details.getSerialNumber());
if (details != null) {
ManufacturerDetails manufacturerDetails = details.getManufacturerDetails();
if (manufacturerDetails != null) {
URI manufacturerUri = manufacturerDetails.getManufacturerURI();
if ((manufacturerUri != null && manufacturerUri.toString().contains("dresden"))
|| "dresden elektronik".equals(manufacturerDetails.getManufacturer())) {
return new ThingUID(BRIDGE_TYPE, details.getSerialNumber());
}
}
}
return null;
}