Computer is offline in network binding

Tags: #<Tag:0x00007fc90d7f7708> #<Tag:0x00007fc90d7f75f0>

Hi everyone,
I have one computer in my network which I want to track the status with the network binding:

Things:
Thing network:pingdevice:kodi “Kodi” [ hostname=“192.168.0.151”, macAddress=“xx:xx:xx:xx:2f:1b” ]

Items:
Switch KodiOnline “Online” {channel=“network:pingdevice:kodi:online”}
Number:Time KodiLatency “Pingzeit” {channel=“network:pingdevice:kodi:latency”}
DateTime KodiLastseen “Zuletzt gesehen” {channel=“network:pingdevice:kodi:lastseen”}

But this KodiOnline item is always shown in Openhab as OFF. The other values remain as UNDEF

I am using openHAB 3.1.0.M3 running on Ubuntu 20.04.2 LTS

The computer I want to track is running on Windows 10.

Am I doing something wrong?

The windows 10 box might be blocking the ping, try pinging the machine manually from the command line of the OpenHAB host

1 Like

This is working without a problem

root@openhab-ansible:/var/log/openhab# ping 192.168.0.151
PING 192.168.0.151 (192.168.0.151) 56(84) bytes of data.
64 bytes from 192.168.0.151: icmp_seq=1 ttl=128 time=0.218 ms
64 bytes from 192.168.0.151: icmp_seq=2 ttl=128 time=0.311 ms
64 bytes from 192.168.0.151: icmp_seq=3 ttl=128 time=0.458 ms
64 bytes from 192.168.0.151: icmp_seq=4 ttl=128 time=0.384 ms
64 bytes from 192.168.0.151: icmp_seq=5 ttl=128 time=0.299 ms
64 bytes from 192.168.0.151: icmp_seq=6 ttl=128 time=0.460 ms
64 bytes from 192.168.0.151: icmp_seq=7 ttl=128 time=0.398 ms
64 bytes from 192.168.0.151: icmp_seq=8 ttl=128 time=0.250 ms

Maybe worth double checking that the openhab account is able to do the same:

sudo -u openhab ping 192.168.0.151

Any errors show up in your logs with your configuration in the OP?

You are right. The user is not permitted:

root@openhab-ansible:~# sudo -u openhab ping 192.168.0.4
ping: socket: Operation not permitted

I am running openhab in a Proxmox Container. I guess I have to change the permission in proxmox then.

Ok I could fix this with the following command

$ sudo setcap cap_net_raw+p /bin/ping

Ping with user openhab is now working:

root@openhab-ansible:~# sudo -u openhab ping 192.168.0.151
PING 192.168.0.151 (192.168.0.151) 56(84) bytes of data.
64 bytes from 192.168.0.151: icmp_seq=1 ttl=128 time=0.233 ms
64 bytes from 192.168.0.151: icmp_seq=2 ttl=128 time=0.442 ms

But the item is still shown as OFF

I changed the log level to trace:
log:set TRACE org.openhab.binding.network

But in the log I only see the following:
2021-04-08 09:53:45.063 [TRACE] [g.network.internal.PresenceDetection] - Perform java ping presence detection for 192.168.0.151

Interesting - I am also using OH3 in an LXC container on Proxmox, on an Ubuntu 20.04 base, same as you.

How did you install openHAB? I followed the apt based install guide. I didn’t have to mess around with any permissions at all - ping worked immediately.

It may be worth stopping and starting the container again, to make sure all openHAB configurations are properly registered.

2 Likes

After a restart it seems to be working.

2021-04-08 12:48:29.583 [TRACE] [g.network.internal.PresenceDetection] - Perform native ping presence detection for 192.168.0.151

2021-04-08 12:48:29.589 [DEBUG] [network.internal.utils.LatencyParser] - Parsing latency from input 64 bytes from 192.168.0.151: icmp_seq=1 ttl=128 time=0.238 ms

2021-04-08 12:48:29.590 [DEBUG] [g.network.internal.PresenceDetection] - Getting latency from ping result PingResult{success=true, responseTimeInMS=0.238, executionTimeInMS=4.0} using latency mode false

Thank you for your help

1 Like