Ping a local device

Is there a way to ping a local device to see if it’s online or not ?

What type of device Zwave, Zigbee, or IP?

1 Like

ip it’s my XBMC machine i would like to know if it’s on or off

you should be able to do a hubaction - enable the web interface on it perhaps?

1 Like

@Kristopher Kubicki put this together a while back and I’ve used this code to verify IP connectivity to my roomba devicetype. This should help. Sadly right now there is no way to do an actual ICMP ping from the hub. Another way that may work is to put your XBMC machine on a SmartPower Outlet and use the power consumption to tell if its on or off.

thats what i was thinking of doing adding it to a power reader but i was hoping to save the cash on that

big thanks @sidjohn1 and @Kristopher works perfect

also @Kristopher you might want to change the hex to port code it having problems i had to do changes of my own to make it work

does anybody know how to shorten up the run time of something say shorten up the run time of the refresh ? i know the default run time is 20 second i would like to change it to like 3 - 4 seconds

1 Like

Thanks @bruceouellette! Can you send me your fork?

Ideally the way to increase the amount of pings is to schedule the poll() with pollster. It will let you bring it down to 1 minute or something like that. You can bring it down further by creating a scheduled smartapp to run the poll() with a bunch of runIn() on the poll. Its sort of hacky, but not horrible.

Let me know if you need any help with it :smile:

Kristopher

I’ve had luck using a Pi to run a script using ping and then reporting status to Smartthings via HTTP GET. I do this for phone presence and also an arduino to monitor and reset the cable modem as well.

I’ll be glad to share!

bs

1 Like

I’m running a v2 hub, does this need to be update to support it?

I’m getting this error on my logs…
4:01:52 PM: error groovy.lang.MissingMethodException: No signature of method: static java.lang.Long.parseLong() is applicable for argument types: (java.lang.Integer) values: [80]
Possible solutions: parseLong(java.lang.String), parseLong(java.lang.String, int) @ line 136

Line 136 def porthex = Long.toHexString(Long.parseLong(dest_port))

Whats in your variable dest_port ?

I tried port 80 and 443. I tested it pointing to a local web server and get the error in the log.

you 100% sure the device you are ping will respond ? for myself my ouya work but not my TV

Just trying this now on my V2 hub and having the same error trying to ping a local webserver on port 8000. Did you ever figure this out?

8:06:17 PM: error groovy.lang.MissingMethodException: No signature of method: static java.lang.Long.parseLong() is applicable for argument types: (java.lang.Integer) values: [8000]
Possible solutions: parseLong(java.lang.String), parseLong(java.lang.String, int)

I have a Pi that I am looking to do just what you described. Could you share?

The code is pretty old but may still be relevant. Go to my GitHub. https://github.com/midyear66

Hope it helps!

Will this work for a local IP address?

  1. I have created virtual switches for all of my PCs
  2. I have created a CoRE piston for each virtual switch that executes a Wake on Lan (WOL) when virtual switch “Changes” to on
  3. I have installed Event Ghost and created a webserver and macros to tell the PC(s) to force Turn Off
  4. I have installed the Send to Event Ghost App for each PC and assigned ports for them.
  5. I have opened these ports in my router

This all works great however, If the PC is switched on or turned off manually then the virtual switch is out of sync.
For 3 of my PCs, I have an Iris Smart Plug that monitors the Power so i am able to use those to sync the status of the Virtual Switches.

However, I would like to be able to use a simple “Pinger” instead of the Iris Plug to check periodically (every 30 seconds?) if the PCs are on or off.

Since the Pi is always on, for my alarm server, I would like to use it to ping the PCs and then report their status to SmartThings…

I got it working on my V2 hub by changing line 136
from
def porthex = Long.toHexString(Long.parseLong(dest_port))
to
def porthex = Long.toHexString(dest_port)

I’m new to SmartThings (and Groovy), so i’m not sure if this is the correct way to do this, but it seems to work for me.

I[quote=“rontalley, post:17, topic:18109”]
Will this work for a local IP address? 1. I have created virtual switches for all of my PCs2. I have created a CoRE piston for each virtual switch that executes a Wake on Lan (WOL) when virtual switch “Changes” to on3. I have installed Event Ghost and created a webserver and macros to tell the PC(s) to force Turn Off4. I have installed the Send to Event Ghost App for each PC and assigned ports for them.5. I have opened these ports in my router

This all works great however, If the PC is switched on or turned off manually then the virtual switch is out of sync. For 3 of my PCs, I have an Iris Smart Plug that monitors the Power so i am able to use those to sync the status of the Virtual Switches.

However, I would like to be able to use a simple “Pinger” instead of the Iris Plug to check periodically (every 30 seconds?) if the PCs are on or off.

Since the Pi is always on, for my alarm server, I would like to use it to ping the PCs and then report their status to SmartThings…
[/quote]

Solution is Host Pinger! Works Great!!

I would like to see how your ping your phone and use for presence. I was thinking this same thing to use as an alternate arrival detection.