]> git.basschouten.com Git - openhab-addons.git/commitdiff
[sonos] Avoid empty thing (type) ID in discovery (#12626)
authorlolodomo <lg.hc@free.fr>
Mon, 18 Apr 2022 17:36:56 +0000 (19:36 +0200)
committerGitHub <noreply@github.com>
Mon, 18 Apr 2022 17:36:56 +0000 (19:36 +0200)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/discovery/ZonePlayerDiscoveryParticipant.java

index a497d09305a2c1897d397b63224865d2438014ff..8fbbd06a16ed21e091cb572baf8650ed6e042c5e 100644 (file)
@@ -82,7 +82,8 @@ public class ZonePlayerDiscoveryParticipant implements UpnpDiscoveryParticipant
             if (device.getDetails().getManufacturerDetails().getManufacturer().toUpperCase().contains("SONOS")) {
                 String id = SonosXMLParser
                         .buildThingTypeIdFromModelName(device.getDetails().getModelDetails().getModelName());
-                if (!"Sub".equalsIgnoreCase(id)) {
+                String udn = device.getIdentity().getUdn().getIdentifierString();
+                if (!id.isEmpty() && !"Sub".equalsIgnoreCase(id) && !udn.isEmpty()) {
                     ThingTypeUID thingTypeUID = new ThingTypeUID(SonosBindingConstants.BINDING_ID, id);
                     if (!SonosBindingConstants.SUPPORTED_KNOWN_THING_TYPES_UIDS.contains(thingTypeUID)) {
                         // Try with the model name all in uppercase
@@ -96,9 +97,8 @@ public class ZonePlayerDiscoveryParticipant implements UpnpDiscoveryParticipant
                         }
                     }
 
-                    logger.debug("Discovered a Sonos '{}' thing with UDN '{}'", thingTypeUID,
-                            device.getIdentity().getUdn().getIdentifierString());
-                    return new ThingUID(thingTypeUID, device.getIdentity().getUdn().getIdentifierString());
+                    logger.debug("Discovered a Sonos '{}' thing with UDN '{}'", thingTypeUID, udn);
+                    return new ThingUID(thingTypeUID, udn);
                 }
             }
         }