Skip to content

Commit

Permalink
stabilize nanoleaf binding:suppress ipv6 addresses in controller disc…
Browse files Browse the repository at this point in the history
…overy

Signed-off-by: Stefan Höhn <[email protected]>
  • Loading branch information
stefan-hoehn-nfon committed Nov 9, 2024
1 parent f37f39c commit 9947bb9
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import static org.openhab.binding.nanoleaf.internal.NanoleafBindingConstants.*;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -66,6 +68,15 @@ public String getServiceType() {
}
final Map<String, Object> properties = new HashMap<>(2);
String host = service.getHostAddresses()[0];
try {
if (InetAddress.getByName(host).getAddress().length != 4) {
logger.info("Ignoring IPv6 address for nanoleaf controllers: {}", host);
return null;
}
} catch (UnknownHostException e) {
logger.error("Error while checking IP address for nanoleaf controller: {}", host);
return null;
}
properties.put(CONFIG_ADDRESS, host);
int port = service.getPort();
properties.put(CONFIG_PORT, port);
Expand Down

0 comments on commit 9947bb9

Please sign in to comment.