[2.2.7] ICMP Ping for Apps and Drivers

hubitat.helper.NetworkUtils.ping(String IPAddress)
hubitat.helper.NetworkUtils.ping(String IPAddress, Integer count)

returns

hubitat.helper.NetworkUtils.PingData:
Double rttAvg
Double rttMin
Double rttMax
Integer packetsTransmitted
Integer packetsReceived
Integer packetLoss

Count has a maximum of 5 and defaults to 3.

Example usage:

hubitat.helper.NetworkUtils.PingData pingData = hubitat.helper.NetworkUtils.ping("192.168.1.1", 5)

Example return:

PingData(rttAvg: 1.035, rttMin: 0.732, rttMax: 1.245, packetsTransmitted: 3, packetsReceived: 3, packetLoss: 0)
16 Likes

@bcopeland. Hi I am not getting good data returned, just all 0's. I am running 2.2.7.126.

Returned Example:
PingData(rttAvg: 0.0, rttMin: 0.0, rttMax: 0.0, packetsTransmitted: 0, packetsReceived: 0, packetLoss: 0)

Code --------

def CheckDevice() {

hubitat.helper.NetworkUtils.PingData pingData = hubitat.helper.NetworkUtils.ping("192.168.1.1", 5)

log.info pingData

}

It worked initially, but since about 2.2.7.121 if the destination does not respond it returns all zeros - just coded around it in my driver ([Release] Hubitat Ping)