import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Pattern;
import javax.jmdns.ServiceInfo;
public class DraytonWiserMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(DraytonWiserMDNSDiscoveryParticipant.class);
+ private final Pattern findIllegalChars = Pattern.compile("[^A-Za-z0-9_-]");
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
if (addresses.length > 0 && addresses[0] != null) {
properties.put(PROP_ADDRESS, addresses[0].getHostAddress());
properties.put(REFRESH_INTERVAL, DEFAULT_REFRESH_SECONDS);
+
+ return DiscoveryResultBuilder.create(uid).withProperties(properties)
+ .withRepresentationProperty(PROP_ADDRESS).withLabel("Heat Hub - " + service.getName())
+ .build();
}
- return DiscoveryResultBuilder.create(uid).withProperties(properties)
- .withRepresentationProperty(PROP_ADDRESS).withLabel("Heat Hub - " + service.getName()).build();
}
}
return null;
if (service.getType() != null && service.getType().equals(getServiceType())
&& service.getName().contains("WiserHeat")) {
logger.trace("Discovered a Drayton Wiser Heat Hub thing with name '{}'", service.getName());
- return new ThingUID(THING_TYPE_BRIDGE, service.getName());
+ return new ThingUID(THING_TYPE_BRIDGE, findIllegalChars.matcher(service.getName()).replaceAll(""));
}
return null;
}