ping my smartphone

28 views
Skip to first unread message

steven surinx

unread,
Aug 18, 2019, 10:41:54 AM8/18/19
to OpenRemote
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

Robnas

unread,
Aug 19, 2019, 8:20:34 AM8/19/19
to OpenRemote
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

steven surinx

unread,
Aug 25, 2019, 8:03:15 AM8/25/19
to OpenRemote
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)");
                    } 
                                 }          
            


Op maandag 19 augustus 2019 14:20:34 UTC+2 schreef Robnas:

Robnas

unread,
Sep 17, 2019, 7:44:13 AM9/17/19
to openremot...@googlegroups.com

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
Reply all
Reply to author
Forward
0 new messages