Skip to content

Commit

Permalink
[sonos] Filter Sonos Sub from discovery (openhab#10925)
Browse files Browse the repository at this point in the history
Fix openhab#10777

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and thinkingstone committed Nov 7, 2021
1 parent 65c2515 commit bc0c581
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
public @Nullable ThingUID getThingUID(RemoteDevice device) {
if (device.getDetails().getManufacturerDetails().getManufacturer() != null) {
if (device.getDetails().getManufacturerDetails().getManufacturer().toUpperCase().contains("SONOS")) {
boolean ignored = false;
String modelName = getModelName(device);
switch (modelName) {
case "ZP80":
Expand All @@ -94,22 +95,28 @@ public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
case "Arc SL":
modelName = "ArcSL";
break;
case "Sub":
// The Sonos Sub is ignored
ignored = true;
break;
default:
break;
}
ThingTypeUID thingUID = new ThingTypeUID(SonosBindingConstants.BINDING_ID, modelName);
if (!SonosBindingConstants.SUPPORTED_KNOWN_THING_TYPES_UIDS.contains(thingUID)) {
// Try with the model name all in uppercase
thingUID = new ThingTypeUID(SonosBindingConstants.BINDING_ID, modelName.toUpperCase());
// In case a new "unknown" Sonos player is discovered a generic ThingTypeUID will be used
if (!ignored) {
ThingTypeUID thingUID = new ThingTypeUID(SonosBindingConstants.BINDING_ID, modelName);
if (!SonosBindingConstants.SUPPORTED_KNOWN_THING_TYPES_UIDS.contains(thingUID)) {
thingUID = SonosBindingConstants.ZONEPLAYER_THING_TYPE_UID;
// Try with the model name all in uppercase
thingUID = new ThingTypeUID(SonosBindingConstants.BINDING_ID, modelName.toUpperCase());
// In case a new "unknown" Sonos player is discovered a generic ThingTypeUID will be used
if (!SonosBindingConstants.SUPPORTED_KNOWN_THING_TYPES_UIDS.contains(thingUID)) {
thingUID = SonosBindingConstants.ZONEPLAYER_THING_TYPE_UID;
}
}
}

logger.debug("Discovered a Sonos '{}' thing with UDN '{}'", thingUID,
device.getIdentity().getUdn().getIdentifierString());
return new ThingUID(thingUID, device.getIdentity().getUdn().getIdentifierString());
logger.debug("Discovered a Sonos '{}' thing with UDN '{}'", thingUID,
device.getIdentity().getUdn().getIdentifierString());
return new ThingUID(thingUID, device.getIdentity().getUdn().getIdentifierString());
}
}
}

Expand Down

0 comments on commit bc0c581

Please sign in to comment.