[hdpowerview] discovery could wrongly return a ThingUID based on a hub's Ipv6 address instead of its Ipv4 address (#8778)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
(cherry picked from commit 5fe7cc5810)
This commit is contained in:
Andrew Fiddian-Green 2020-10-18 19:26:50 +01:00 committed by Fabian Wolter
parent c39d30f552
commit 9b2af50fc6

View File

@ -75,7 +75,9 @@ public class HDPowerViewHubDiscoveryParticipant implements MDNSDiscoveryParticip
@Override
public @Nullable ThingUID getThingUID(ServiceInfo service) {
for (String host : service.getHostAddresses()) {
return new ThingUID(THING_TYPE_HUB, host.replace('.', '_'));
if (VALID_IP_V4_ADDRESS.matcher(host).matches()) {
return new ThingUID(THING_TYPE_HUB, host.replace('.', '_'));
}
}
return null;
}