Getting the Source IP Address in parse() method?

I have LAN-connected devices that will send messages to SmartThings Hub which will be passed to my device-handler’s parse() method

Is there a way to know the IP address of the caller? The parseLanMessage doesn’t have the source IP address.

def parse(description) {
def msg = parseLanMessage(description)

def headersAsString = msg.header // => headers as a string
def headerMap = msg.headers      // => headers as a Map
def body = msg.body              // => request body as a string
def status = msg.status          // => http status code of the response
def json = msg.json              // => any JSON included in response body, as a data structure of lists and maps
def xml = msg.xml                // => any XML included in response body, as a document tree structure
def data =              // => either JSON or XML in response body (whichever is specified by content-type header in response)



1 Like

In my app (using UDP comms), I use the below code:

def parseDeviceData(response) {
	def resp = parseLanMessage(response.description)
	def deviceIp = convertHexToIP(resp.ip)}


private String convertHexToIP(hex) {

If you are using TCP, It will look something like the below (evt is the same as response in yours).

def parsedEvent = parseLanMessage(evt.description)
logDebug("ssdpHandler:  parsedEvent = ${parsedEvent}")
def ip = convertHexToIP(parsedEvent.networkAddress)

There are other possible variations, just play around with it.