How to ping a network device from a rule

I have several devices using the Network binding (in OH2.1). The problem I am seeing is that my Samsung TV binding occasionally goes OFFLINE (don’t know why - maybe some sort of internal update?) while the TV is still on. This triggers my TV off rules (but really the TV is still on).

The Network (binding) status shows as ONLINE (as it only checks every 60 seconds). What I was wanting to do is to trigger a manual ping of the TV’s ip address to see if it is really offline, before I trigger my “TV OFF” rules.

The Network binding does not seem to provide a way to trigger a manual ping, just a timed one.

Does anyone have a suggestion as to how to trigger a manual ping from a rule and get a ONLINE or OFFLINE status back? maybe using the exec binding?

I’m on a linux box, and have both ping and arping available.

Thanks.

I think you will have to use a Rule and/or the Exec binding. I found a script here:

If you run that from a Rule or Exec binding Item you can get back an ON or OFF (will have to slightly modify the script). Since you want to do this as part of a Rule already I’d recommend the executeCommandLine approach.

1 Like

Did you find a simple Comand to ping a client? Would want to make a rule to return the status!

Hi,

I would like to bring this topic up again as I am currently looking for the same feature.
What I want is an action to use in rules that force a ping to be performed. What I am wanting to do is forcing a ping to my phone as soon as there is a motion detected outside so that the system knows that I am at home now, ideally before any door is being opened so that no alarm is being triggered (would be the case if a door is being opened but noone is home).

If you are running Android you can use the openHAB app on the phone to report the Wi-Fi name to OH and if the Wi-Fi name matches yours you know the phone has just joined the network. I suspect that the iPhone app has a similar capability.

You could also set up a task in Tasker to report when the phone first joins the network.