PC online item alternates between online - offline

Raspberry Pi4B with openhabian 1.7.1, openhab 3.2.0 release build

I have a network binding item that reflects my Windows 8.1 PC’s online status. But even though the PC is constantly online, every few minutes the status toggles from online to offline and a few minutes later back online.
The thing status does remain online, it is just the binding’s online channel that toggles.
The item is:

Switch DesktopStatus "Desktop Status"  <switch> (gDesktop, gNetworkStatus) ["Status"] {channel="network:pingdevice:Office_DesktopPC:online", autoupdate="false"}

In the openhab log I get the following message every time the item comes online:

2022-01-03 12:49:08.759 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online

while the event log shows:

2022-01-03 12:49:08.926 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DesktopStatus' changed from OFF to ON
2022-01-03 12:54:15.383 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DesktopStatus' changed from ON to OFF

A similar item for my Synology NAS works perfectly and when running OH3 on my PC this problem also didn’t show.

My knowledge of networks is limited, so I don’t know where to find the DHCP listener or how to get more information.

When it shows as OFF, try to run a ping from the openHAB machine to your PC. If that works something is going on with openHAB and/or the binding. If not, there is something “wrong” with your PC or network which is causing it not to respond to pings.

That’s all that the Network binding does, ping the devices. When there is no response from the destination machine it sets the switch to OFF.

Thanks Rich, your suggestion resulted in a number of interesting observations:

  • When the status is ‘off’, a ping on the PC’s hostname doesn’t reply. However, a ping to its IP address does reply. When the status is ‘on’, a ping to hostname or IP both do reply.
  • My NAS (a linux device) that also uses the hostname in the OH thing always reflects the real status without any false toggling.
  • When I start OH3 on my PC (while OH3 on RPi is still running), the PC online status shows online on both systems and remains online on both (even though the PC thing also uses the hostname). When I stop OH3 on the PC, some minutes later the toggling of the online status on RPi resumes.

I don’t know what to conclude out of this except guessing it is a PC problem (that disappears when the PC pings itself, even when it has its hostname in the OH thing as well).
But I do have a work-around now by using the IP address for the PC in the OH thing instead of the hostname.
I prefer using hostnames since my router doesn’t have the option to assign static IPs. It is now on the devices-to-be-upgraded list :slight_smile: