SmartApp not GETting reply when using HubAction GET


(trac starr) #1

I might be missing something here, but when I use HubAction with a GET endpiont, I’m not getting a reply - or at least I don’t know where to look for it.

I know my service is called and the reply is sent (can debug that end). I’m subscribed to location in my smartapp.

If I use a PUT instead (for a different service endpoint) I get a callback to the locationHandler function that I setup with subscribe.

I’ve added a parse function for callback - but that’s not called either - i think this is only for DeviceTypes?

What am I missing?

def hubAction = new physicalgraph.device.HubAction(
method: "GET",
path: uri,
headers: [HOST:getHostAddress()]
)
sendHubCommand(hubAction)

(Joshua Lyon (SharpTools.io Dashboard)) #2

I find that the httpGet, httpPost, and httpPostJson methods work well for this purpose:
http://docs.smartthings.com/en/latest/smartapp-developers-guide/calling-web-services-in-smartapps.html

httpGet(pollParams) { resp ->
   if (resp.data) {
       debugEvent ("Response from GET = ${resp.data}", true)
       debugEvent ("Response Status = ${resp.status}", true)
   }
   if(resp.status == 200) {
       log.debug "poll results returned"
   }
   else {
       log.error "polling children & got http status ${resp.status}"
   }
}

Similiarly:

httpPost(params) { response ->

And

httpPostJson(uri: deviceInfo.callbackUrl, path: "",  body: [evt: [deviceId: evt.deviceId, name: evt.name, value: evt.value]]){response ->

(trac starr) #3

Problem is that if I’m not mistaken these only work for devicetypes (not sure) but also don’t allow LAN connection?

But, to be honest, I don’t think i’ve tested using a local IP. I’ve just assumed, with all the other posts using the hubaction for LAN services, that that is the only way.


(Joshua Lyon (SharpTools.io Dashboard)) #4

Ah, I didn’t realize it was for a local LAN connection. I use these methods with an End Point SmartApp to call other externally facing web services.