ping my smartphone

hello,
I would like to ping my phone’s ip (fixed) so i can control some actions with it when i’am on my network and i was thinking i run a shell script that returns a message or value.

The script works from terminal, but i can’t get the value in OR, the label shows “N/A”.

Or should i use some other methode.

i tried to ping it in Node-red , it also works but then i got stuc to get it to OR.

i just needs some hints

greatings steven

pingUser.PNG

script.PNG

sensor.PNG

Steven,

this works for me:

ping -c 1 -W 2 localhost > ping-me.txt 2>&1 && echo online || echo offline

dont forget to make the shell script executable

change localhost to the desired ip adress, i have the script in the /openremote/bin dir

than make a custom sensor it will show you if you online or offline

hope it helps

thanks for the reply, but still no luk, it works in terminal and text file is updatet but the sensor in OR isn’t
now i was thinking of using java code in the rules, is it possible to use something like this

rule " homechecker"

timer(int: 5s)

function getIpStatus(){

      String ipAddress = "192.168.0.20";

       InetAddress inet = InetAddress.getByName(ipAddress);

              if (inet.isReachable(5000))

{

   execute.command("homeStatus on.(on)");      /* i switch a virtual relaycontact

        }

else {

         execute.command("homeStatus off.(off)");

                }

}

you have to create a custom sensor which reads the reply from the above command (shell script) but you already have that as i can see

if you tie a label in designer to the sensor it will show if offline of online. clear the sensornames field in your shell command its not needed