Need some help getting JSON response from LAN

Based on searching through the forums, I realize that there are some issues using httpget on LAN addresses. I discovered the sendhubcommand workaround to pull information, but I’m not sure how to actually get the result into a string to parse the response. Below is a rough example of where I’m at:

def returnJSON() {
def result = new physicalgraph.device.HubAction(
    method: "GET",
    path: "/jsonrpc?request=xxxxx",
    headers: [
        HOST: ""
log.debug "Hub command sent"

I hope someone can help me understand how to get the response so I use another function to parse it down (or to even test whether the hub is sending the request). I am a bit new to programming, so I might be missing something obvious or straight forward, so any advice would be appreciated.

You need to implement a parse method - it will receive the response (assuming that you have set up your deviceNetworkId correctly (either hex IP:Port or MAC):

def parse(String description) {
	def msg = parseLanMessage(description)
        def json = msg.json;
       // parse and process your json here

@ahndee I actually converted my IP to hexIP:Port in the host section, I also added the parse method, but it doesn’t seem to be working. I put a log.debug statement in there, and it isn’t showing up in the logging. Not sure what I’m doing wrong or how to test this.

@anon36505037 I am trying to build on an existing smartapp that controls lighting using Kodi. I wanted to add additional logic into the app to exclude certain types of videos. Kodi will return the info I want from an HTTP request, so I want to build this into the existing app if possible.

Try using the target device’s MAC address as network ID - seems to be more robust.

It looks like after tinkering/debugging it last night that the device is receiving the GET request and returning the info as expected. The issue appears to be that smartthings will not pass the response to the parse method in a smartapp, and only in a device handler. I know how to send commands from a smartapp to a device handler, but if anyone can help me obtain the parsed string from a device handler back into the smartapp it would be appreciated.