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",
    method:"GET",
    headers: headers ))
    log.debug "rsult = "+rsult
  rsult
  }

where destIp = “192.168.0.5” & 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.

1
1
Controller

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?

Dear,

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" ?>
<real_time_data>
Normal
<Vac_l1>229.9</Vac_l1>
<Vac_l2>225.9</Vac_l2>
<Vac_l3>234.2</Vac_l3>
<Iac_l1>1.23</Iac_l1>
<Iac_l2>1.19</Iac_l2>
<Iac_l3>1.23</Iac_l3>
49.98
49.99
49.97
239
234
247
720
29.8
4.74
5.3
959.40
956.52
975.6
298.7
714.6
-
711.5
2480
1.24
-
-
-
0.69
-
-
-
-
-
-
-
</real_time_data>
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
HOST: 192.168.1.221:80

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:192.168.1.221:80]
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 192.168.1.221 and the converted hex code is c0a801dd
3a0fa8f1-a32c-4223-8bc9-8bd32ddea5a1 2:13:23 PM: trace Poll Called