diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/BaseAddonSuggestionFinder.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/BaseAddonSuggestionFinder.java index 6f777ad9b0c..b4ee8fa82b0 100644 --- a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/BaseAddonSuggestionFinder.java +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/BaseAddonSuggestionFinder.java @@ -58,6 +58,7 @@ public void close() { public abstract Set getSuggestedAddons(); public void setAddonCandidates(List candidates) { + addonCandidates.clear(); addonCandidates.addAll(candidates); } } diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/MDNSAddonSuggestionFinder.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/MDNSAddonSuggestionFinder.java index 8c473679588..bf4dfa8d387 100644 --- a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/MDNSAddonSuggestionFinder.java +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/MDNSAddonSuggestionFinder.java @@ -82,15 +82,18 @@ public Set getSuggestedAddons() { addonCandidates.forEach(candidate -> { candidate.getDiscoveryMethods().stream().filter(method -> SERVICE_TYPE.equals(method.getServiceType())) .forEach(method -> { - Map map = method.getMatchProperties().stream().collect( + Map matchProperties = method.getMatchProperties().stream().collect( Collectors.toMap(property -> property.getName(), property -> property.getPattern())); services.values().stream().forEach(service -> { if (method.getMdnsServiceType().equals(service.getType()) - && propertyMatches(map, NAME, service.getName()) - && Collections.list(service.getPropertyNames()).stream().allMatch( - name -> propertyMatches(map, name, service.getPropertyString(name)))) { - result.add(candidate); - logger.debug("Addon '{}' will be suggested (via mDNS)", candidate.getUID()); + && propertyMatches(matchProperties, NAME, service.getName())) { + List serviceProperties = Collections.list(service.getPropertyNames()); + if (serviceProperties.containsAll(matchProperties.keySet()) + && serviceProperties.stream().allMatch(name -> propertyMatches(matchProperties, + name, service.getPropertyString(name)))) { + result.add(candidate); + logger.debug("Addon '{}' will be suggested (via mDNS)", candidate.getUID()); + } } }); }); diff --git a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/UpnpAddonSuggestionFinder.java b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/UpnpAddonSuggestionFinder.java index d3f652a5aad..805ddbd9930 100644 --- a/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/UpnpAddonSuggestionFinder.java +++ b/bundles/org.openhab.core.config.discovery.addon/src/main/java/org/openhab/core/config/discovery/addon/finders/UpnpAddonSuggestionFinder.java @@ -137,10 +137,10 @@ public Set getSuggestedAddons() { addonCandidates.forEach(candidate -> { candidate.getDiscoveryMethods().stream().filter(method -> SERVICE_TYPE.equals(method.getServiceType())) .forEach(method -> { - Map map = method.getMatchProperties().stream().collect( + Map matchProperties = method.getMatchProperties().stream().collect( Collectors.toMap(property -> property.getName(), property -> property.getPattern())); - Set propNames = new HashSet<>(map.keySet()); + Set propNames = new HashSet<>(matchProperties.keySet()); propNames.removeAll(SUPPORTED_PROPERTIES); if (!propNames.isEmpty()) { logger.warn("Addon '{}' addon.xml file contains unsupported 'match-property' [{}]", @@ -184,15 +184,15 @@ public Set getSuggestedAddons() { } } - if (propertyMatches(map, DEVICE_TYPE, deviceType) - && propertyMatches(map, MANUFACTURER, manufacturer) - && propertyMatches(map, MANUFACTURER_URL, manufacturerURL) - && propertyMatches(map, MODEL_NAME, modelName) - && propertyMatches(map, MODEL_NUMBER, modelNumber) - && propertyMatches(map, MODEL_DESCRIPTION, modelDescription) - && propertyMatches(map, MODEL_URL, modelURL) - && propertyMatches(map, SERIAL_NUMBER, serialNumber) - && propertyMatches(map, FRIENDLY_NAME, friendlyName)) { + if (propertyMatches(matchProperties, DEVICE_TYPE, deviceType) + && propertyMatches(matchProperties, MANUFACTURER, manufacturer) + && propertyMatches(matchProperties, MANUFACTURER_URL, manufacturerURL) + && propertyMatches(matchProperties, MODEL_NAME, modelName) + && propertyMatches(matchProperties, MODEL_NUMBER, modelNumber) + && propertyMatches(matchProperties, MODEL_DESCRIPTION, modelDescription) + && propertyMatches(matchProperties, MODEL_URL, modelURL) + && propertyMatches(matchProperties, SERIAL_NUMBER, serialNumber) + && propertyMatches(matchProperties, FRIENDLY_NAME, friendlyName)) { result.add(candidate); logger.debug("Addon '{}' will be suggested (via UPnP)", candidate.getUID()); }