Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nanoleaf] Suppress ipv6 addr in controller discovery #17724

Merged
merged 5 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions bundles/org.openhab.binding.nanoleaf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,8 @@ The controller thing has the following parameters:
**Important note on the topic of IPV6 ip addresses:**

With firmware version 8.5.2 or newer, panels may change between being OFFLINE and ONLINE.
This is due to the fact that if they are discovered with IPv6 addresses, the binding is not able to correctly send API requests to the devices.
It is therefore recommended to disable IPv6 on the openHAB server.

This can e.g. be achieved on openHABian the following way:

```shell
sudo nano /etc/sysctl.conf`
```

Add the following at the bottom of the file:

```ini
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
```
This is because if they are discovered with IPv6 addresses, the binding is not able to correctly send API requests to the devices which leads to an unstable behaviour.
To avoid this, the binding will only discover devices based on their IPv4 address.

Reboot your server after the change.

Expand Down
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.debug("Ignoring IPv6 address for nanoleaf controllers: {}", host);
return null;
}
} catch (UnknownHostException e) {
logger.error("Error while checking IP address for nanoleaf controller: {}", host);
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
return null;
}
properties.put(CONFIG_ADDRESS, host);
int port = service.getPort();
properties.put(CONFIG_PORT, port);
Expand Down