Device Discovery with IPV4 and IPV6 results into two devices

During the development of both the Nanoleaf and the Govee Binding I ran into issues with IPV6. Therefore on Nanoleaf I even had to mention that the devices will be unreliable when in IPV6.

In particular with the introduction with Matter which requires (IPV6) to be switched on and of course in general would we want to support both, I like to jump on that issue and solve it for good.

The problem with Govee is during discovery which I like to concentrate on. When I run the discovery (code) and IPV6 is switched on I will receive two results: one for IPV4 and IPV6.

Not only is that confusing for a user, it also led to issues if the same physical device was added as two things via two different ip addresses (at least this is something that I remember).

I am aware that one could check the Network Interface type via if netAddress instanceof Inet4Address and I have seen several bindings following this approach (if v4 return interface else null) but I wonder if this is the right approach?

  • AFAIK, there is no easy way to find out if these two same results are equal to the same device, so one could be suppressed.
  • And even if there was: Would we only show one and then which one, v4 or v6?
  • Or should we always show both and how can we tell the openHAB user that these two things are actually one?
  • If one thing has been added would we then suppress the other one?

Is there anyone who ever stumbled upon this topic and has a clever solution or approach? Or is there even a recommended approach?

TIA
Stefan

Just a thought but why couldn’t you just look at the MAC address of the device and if the MAC is same for ipv4 and ipv6 then then allow user to define default IP protocol to use for that device?

Checking the MAC Adress will be good for preventing duplicate discovery results, but at this stage, there is no user interaction, so no protocol selection possible.
The discovery method would need to combine both results and store the network information for both results as thing properties. After aproving the thing a decision in the config can be made which protocol to use.
I don‘t really know if the combination of two discovery results could be possible or if core changes are needed


First of all, I like the idea to find out how they are the same.

networkInterface.getHardwareAddress()

reveals the hardware address.

However, as @hmerk stated, we don’t have an interactive process, so some of the questions above still apply what do we do if we encounter two results.

maybe if both are found then by default use ipv4 and allow user to override it later after approving if it was a stored value found during discovery then over riding to the alternate address after the thing is allowed it could due further configurations needed to complete the things setup

Look at the Representation Property (see below). If your thing uses IP address as the Representation Property then you will indeed have two different things for IPv4 and IPv6. So you need to find a property of the thing that is unique to the particular device but common across IPv4/6 
 typically something like a serial number (but perhaps a MAC address would do too).

I think MAC would be the most consistent it has a defined length and format that could easily be filtered on. Also it is unique to the device and does not change . Plus is a mandatory value to establish a TCP/IP conversation. Of course if the device has multiple adaptors you would have more then one MAC that may register but that is a way far one off type case.

That‘s clear, but don‘t think it would help, just prevents creation of a second discovery result. We need to find a way to add the network information of the second discovery to the first one, so it can be used for config option.

You dont need to “filter” on anything. If you set it as the Representation Property (see my prior post) then the OH core framework ensures that both such discovered things are treated as a single discovery result.

But which network information will be used ? V4 or V6 ??? I guess the first to be found.

You confuse me. The OP was asking to prevent duplicate discovery results. But you seem to be asking to force duplicate discovery results. Or??

No, we need to find a way to create a single discovery result with information about both network adresses (V4 and V6) so the user can set the preferred protocol in the Thing config after approval.

Ah. A Schroedinger cat device.

5 Likes