Help! Lan connected xml device trouble getting data back

Hi, hope I’m posting this properly. I’m trying to write a device driver. The device is local, with a static IP address. I set the IP in the settings for the device.

I am able to successfully send a get to the device. The device responds, but I don’t seem to get a response.

I send a hubaction with this code

def headers = [:]
 headers.put("HOST", destIp+":"+destPort)
 headers.put("Content-Type", "application/atom+xml")
 def rsult = sendHubCommand (new physicalgraph.device.HubAction(
    path: "/index.xml",
    headers: headers ))
    log.debug "rsult = "+rsult

where destIp = “” & destPort = “8080”

The message is sent, my device acts, and returns an xml page:
This is pasted from my browser.

This XML file does not appear to have any style information associated with it. The document tree is shown below.


GPIO04 Pin 2 controls the button

The message logged in my parse routing is this:

def parse(String description) {
def msg = parseLanMessage(description, false)
log.debug "msg = "+msg

msg = [index:01, mac:5CCF7F058CDC, ip:C0A80005, port:1F90, requestId:c00b59ba-f4d8-42a5-bc3a-02a64dcd4371]

No xml, no hex coded xml, no body at all. Anyone have a suggestion?

Is this in a device type, or smart app (service manager)? Don’t know if it’ll make a difference, but you shouldn’t need the sendHubCommand if this is a device type

Here’s how I do my xml call in my device type for the BBQ Guru Device Type

def getStatus() {
	log.trace "Get Status Called"
	def userpassascii = "${username}:${password}"
	def userpass = "Basic " + userpassascii.encodeAsBase64().toString()
    def headers = [:] 
    headers.put("HOST", "$deviceIP:$devicePort")
    if (loginRequired) {
        headers.put("Authorization", userpass)
    def result = new physicalgraph.device.HubAction(
        method: "GET",
        path: "/config.xml",
        headers: headers

Also, make sure your deviceNetworkID is set to IP:Port, but in hex

1 Like

Thanks for the help Kevin.

I just double checked deviceNetworkId and that looks good. One thing that I noticed in your code you did not set the content type, so I took that out. Seems like it must be something simple, but i’m running out of ideas. Thanks again,

Yeah, I read your post a few times and each time I had an idea, I started typing it and realized it couldn’t be what I was starting to type. It may be helpful to post a screenshot of what the xml response looks like in the browser to get a better feel for what the response looks like.

What do you get if you log.debug the description in parse before you send it through getlanmessage?

Ok, here is the xml file from the browser, and the message before and after parseLanMessage.

fd2cdfaf-8371-4c3e-af47-a4ad8319966f 10:06:32 PM: debug msg = [index:01, mac:5CCF7F058CDC, ip:C0A80005, port:1F90, requestId:92b3388f-63e8-446a-ac3c-3e4f3a261373]
fd2cdfaf-8371-4c3e-af47-a4ad8319966f 10:06:32 PM: debug Parsing ‘index:01, mac:5CCF7F058CDC, ip:C0A80005, port:1F90, requestId:92b3388f-63e8-446a-ac3c-3e4f3a261373’

Clearly the message is the same.

Tomorrow, I’ll give it a go with your code and see it it will fix my problem. My hub is the original one from way back, do you think it could be a version issue?


I need some help in getting out the data I need from a solar inverter attached to my LAN that I can acces via xlm.
I am not at all experienced in programming so It is very likely that I have it somewhere wrong.
I can see an answer from the inverter in the msg.body but it looks like it is the right data but I don’t know how to get out the values I want. Any help or references is much appreciated (I tried to recycle the code from several forum topics but without success)

At the end of my message is the screenshot of the xml.

For example If I want to add the value from the xml:

def parse(String description) {
//this is automatically called when the hub action returns
log.debug “Got Reply”
def xml = parseLanMessage(description)
log.debug “body: ${xml.body}”

def evt2 = createEvent (name: "voltage", value: ((xml.Vac_l1.text())), unit:"V")
log.debug "evt2: $evt2"
return [evt2]

The log I receive is (please note that there is few days time difference between the log and the xml screenshot which results in different values of the parameters) :

3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:24 PM: error java.lang.NullPointerException: Cannot invoke method text() on null object
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:24 PM: debug body: <?xml version="1.0" ?>
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:24 PM: debug Got Reply
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug GET /real_time_data.xml HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings

3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug Making xml request to C0A801DD:0050
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug Uses which method: null
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug The Header is [HOST:]
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug The device id configured is: C0A801DD:0050
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: debug IP address entered is and the converted hex code is c0a801dd
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: trace Poll Called