Network Binding (arping not working)

Hi, everyone!

Trying to detect if the TV is on (not smart enough), so trying to do it with network binding. It looks like this binding is not using arping, but just ping and this TV is not responding to ping.

Also I found open port on this TV and tried to use it to confirm presence in the network, but it switching all the time ON - OFF - ON - OFF

Any ideas? Thanks in advance!

Last I checked, you have to install a tool to enable arping. You may have done this already, but it’s not clear to me whether that’s the case.

I can’t be of any further help, as I don’t use arping. I control my home theatre with a Logitech Harmony Hub.

Thanks rpwong, but in the first screenshot I showed that arping is working fine in the console and the permissions are correct.

Sure, that’s why I said, “you may have done this already.” Again, I don’t use it, so your screenshots don’t mean anything to me. Since you didn’t reference the documentation or indicate that you’ve read it (which happens a lot, unfortunately), I didn’t want to assume that you were aware of it. :wink:

You may check if increasing the log level of the binding gives more insight into which technique is being used to ping the device. You also may use a network sniffer to check if pings of any type are send to the TV and if there are answers from the TV.
Does your openhab device have more than one ehternet interface ? If that is the case it could be that not the right interface is being used for the ping. Sniffer should help to identify this.

Thanks Wolfgang. Log info says not much:

The packets in wireshark looks fine: arp packets are sent and the TV responds:

But Item is not switching… :face_with_raised_eyebrow:

Opened this project on github and found that I should have logs like “Perform ARP ping detection for {} on interface: {}”, hostname, interface name “, but I can’t see that. So probably these packets from wireshark not from this binding. After reinstalling this binding, it turns out that I have “arpPingUtilMethod = UNKNOWN_TOOL.” But I have IPUTILS_ARPING. Code found:

public ArpPingUtilEnum determineNativeARPpingMethod(String arpToolPath) {
        String result = ExecUtil.executeCommandLineAndWaitResponse(Duration.ofMillis(100), arpToolPath, "--help");
        if (result == null || result.isBlank()) {
            return ArpPingUtilEnum.UNKNOWN_TOOL;
        } else if (result.contains("Thomas Habets")) {
            if (result.matches("(?s)(.*)w sec Specify a timeout(.*)")) {
                return ArpPingUtilEnum.THOMAS_HABERT_ARPING;
            } else {
                return ArpPingUtilEnum.THOMAS_HABERT_ARPING_WITHOUT_TIMEOUT;
            }
        } else if (result.contains("-w timeout")) {
            return ArpPingUtilEnum.IPUTILS_ARPING;
        } else if (result.contains("Usage: arp-ping.exe")) {
            return ArpPingUtilEnum.ELI_FULKERSON_ARP_PING_FOR_WINDOWS;
        }
        return ArpPingUtilEnum.UNKNOWN_TOOL;
    }

But I have output like this:

cv

timeout in brackets. This is probably why it was recognized as UNKNOWN_TOOL. Next I look at this code:

public boolean performPresenceDetection(boolean waitForDetectionToFinish) {
        if (executorService != null) {
            logger.debug(
                    "There is already an ongoing presence discovery for {} and a new one was issued by the scheduler! TCP Port {}",
                    hostname, tcpPorts);
            return false;
        }

        if (!cache.isExpired()) {
            return false;
        }

        Set<String> interfaceNames = null;

        currentCheck = 0;
        detectionChecks = tcpPorts.size();
        if (pingMethod != null) {
            detectionChecks += 1;
        }
        if (arpPingMethod != ArpPingUtilEnum.UNKNOWN_TOOL) {
            interfaceNames = networkUtils.getInterfaceNames();
            detectionChecks += interfaceNames.size();
        }

        if (detectionChecks == 0) {
            return false;
        }

        final ExecutorService executorService = getThreadsFor(detectionChecks);
        this.executorService = executorService;

        for (Integer tcpPort : tcpPorts) {
            executorService.execute(() -> {
                Thread.currentThread().setName("presenceDetectionTCP_" + hostname + " " + String.valueOf(tcpPort));
                performServicePing(tcpPort);
                checkIfFinished();
            });
        }

        // ARP ping for IPv4 addresses. Use single executor for Windows tool and
        // each own executor for each network interface for other tools
        if (arpPingMethod == ArpPingUtilEnum.ELI_FULKERSON_ARP_PING_FOR_WINDOWS) {
            executorService.execute(() -> {
                Thread.currentThread().setName("presenceDetectionARP_" + hostname + " ");
                // arp-ping.exe tool capable of handling multiple interfaces by itself
                performARPping("");
                checkIfFinished();
            });
        } else if (interfaceNames != null) {
            for (final String interfaceName : interfaceNames) {
                executorService.execute(() -> {
                    Thread.currentThread().setName("presenceDetectionARP_" + hostname + " " + interfaceName);
                    performARPping(interfaceName);
                    checkIfFinished();
                });
            }
        }

I’m not a programmer, but it looks like “performARPping()” never will be called because "interfaceNames == null ", because “arpPingMethod == ArpPingUtilEnum.UNKNOWN_TOOL”. Сorrect me if I’m wrong.

as far as I can see your conclusions are correct.
I was not able to find any information about the OS that you run OH on.
Indeed the search for switch w could be a bit enhanced ( you may fill a github issue for this )

I was not able to find any information about the OS that you run OH on.

It is on first screenshot: Ubuntu 20.04, and “arping from iputils s20190709”

Install the arping package. It contains a version that should be detected.
As far as I can see it contains the strings “Thomas Habets” and “w sec Specify a timeout” and thus should work.