Repository: openhab/openhab-addons

Issue #6347: [keba] Unable to establish connection to wallbox
Created: 2019-11-06T23:11:13Z
Expected Behavior
Binding should connect to configured wallbox and do its job.
Current Behavior
The binding tries to check for the existence of the configured wallbox in class KeContactHandler.pollingRunnable using InetAddress.isReachable
        if (!InetAddress.getByName(((String) getConfig().get(IP_ADDRESS))).isReachable(PING_TIME_OUT)) {

Unfortunately this check fails and the whole binding is not activated.
As far as I understand, the isReachable() method tries to perform a ping to the configured IP address (which works fine from the Raspi command line). For this ping to succeed from the Java code, openhab would require to be started as root user (which of course is not recommended at all). For testing I installed the 2.4.0 binding and started openhab as root user. The trace logging indicated a successful existence of the wallbox (but failed with some other exceptions later). So I assume the missing access rights cause the failure.
Possible Solution
Instead of running openhab as root, I added a fallback check to the http port. It first performs the current isReachable check. In case of failure (which is true for my system all the time), it tries to open a socket to the http port (80). This works like a charm in my environment (I run my modified 2.3.0 keba binding for over a year now).
private boolean checkKeba() throws IOException {
    boolean isReachable = InetAddress.getByName(((String) getConfig().get(IP_ADDRESS))).isReachable(PING_TIME_OUT);

    if (!isReachable) {
        logger.debug("InetAddress.isReachable failed, trying http port");

        SocketAddress sockAddr = new InetSocketAddress((String) getConfig().get(IP_ADDRESS),
                REMOTE_CHECK_PORT_NUMBER);
        Socket socket = new Socket();

        try {
            socket.connect(sockAddr, PING_TIME_OUT);
            isReachable = true;
        } finally {
            socket.close();
        }

    }
    logger.debug("checkKeba returns {}", isReachable);
    return isReachable;
}

I am not so familiar with forking and creating a pull request. Maybe somebody else could add that to the master branch, so I don't have to modify the code for each new version of the binding. :-)
Your Environment
Version used: openhab 2.4.0 stable, keba binding 2.4.0
Operating System and version: openHABianPi 4.19.66 on Raspberry Pi 3 B+
Keba Wallbox P30 x-series with firmware 3.9.10 connected via lan

Duplicate issue #7324: [keba] Ping timed out after '3003' milliseconds
Created: 2020-04-08T18:26:58Z
openhab 2.5 + binding-keba-2.5.3
Items on sitemap not updated, the communication with Wallbox is not working as expected
Expected Behavior
The keba items present in the sitemap should be updated
Current Behavior
The communication between openhab and Keba wallbox is not working.
The Wallbox itself is configured properly and has been proven by sending UDP request from the raspberry to the wallbox, the wallbox sends the expected answers back to the raspberry.
The debug-log shows right after the state change from "initializing" to "online" a ping timeout, after that the KEBA KeContact transceiver is stopped.
Debug-log
2020-04-07 23:29:40.548 [thome.event.ExtensionEvent] - Extension 'binding-keba' has been installed.
2020-04-07 23:29:40.732 [hingStatusInfoChangedEvent] - 'keba:kecontact:eae1d7ed' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
==> /var/log/openhab2/openhab.log <==
2020-04-07 23:29:40.749 [TRACE] [nternal.handler.KeContactTransceiver] - There are now 1 KEBA KeContact handlers registered with the transceiver
2020-04-07 23:29:40.751 [DEBUG] [nternal.handler.KeContactTransceiver] - Starting the the KEBA KeContact transceiver
2020-04-07 23:29:40.755 [INFO ] [nternal.handler.KeContactTransceiver] - Listening for incoming data on /0.0.0.0:7090
2020-04-07 23:29:40.761 [DEBUG] [nternal.handler.KeContactTransceiver] - Establishing the connection to the KEBA KeContact 'keba:kecontact:eae1d7ed'
2020-04-07 23:29:40.763 [TRACE] [nternal.handler.KeContactTransceiver] - Connecting the channel for /10.0.0.43:7090
==> /var/log/openhab2/events.log <==
2020-04-07 23:29:40.788 [hingStatusInfoChangedEvent] - 'keba:kecontact:eae1d7ed' changed from INITIALIZING to ONLINE
==> /var/log/openhab2/openhab.log <==
2020-04-07 23:29:43.781 [DEBUG] [ba.internal.handler.KeContactHandler] - Ping timed out after '3003' milliseconds
2020-04-07 23:29:43.785 [TRACE] [nternal.handler.KeContactTransceiver] - There are now 0 KEBA KeContact handlers registered with the transceiver
2020-04-07 23:29:43.798 [DEBUG] [nternal.handler.KeContactTransceiver] - Stopping the the KEBA KeContact transceiver
2020-04-07 23:30:16.811 [DEBUG] [ba.internal.handler.KeContactHandler] - Ping timed out after '3004' milliseconds
2020-04-07 23:30:16.816 [TRACE] [nternal.handler.KeContactTransceiver] - There are now 0 KEBA KeContact handlers registered with the transceiver

Closing comment (2020-04-24T22:21:36Z): Yes, this issue can be closed as a duplicate of #6347.