From c541776f7d154efd0049809b7c580b1635037d22 Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sun, 13 Dec 2020 16:18:38 +0100 Subject: [PATCH] [deconz] fix gateway discovery (#9362) Signed-off-by: Jan N. Klug --- .../discovery/BridgeDiscoveryParticipant.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/BridgeDiscoveryParticipant.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/BridgeDiscoveryParticipant.java index bcaf26a06..420479270 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/BridgeDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/BridgeDiscoveryParticipant.java @@ -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 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; }