sendHubCommand - for SmartThings staffers please

Sorry for yet another thread on this (there are quite a number of them here), but I don’t recall seein any definitive answers to the following when used from within a SmartApp…

The following works well, and is a mainstay for communicationg with my HA server via HAM Bridge:

sendHubCommand(new physicalgraph.device.HubAction("""GET /<Path>/?<Params> HTTP/1.1\r\nHOST: <IP:Port>\r\n\r\n""", physicalgraph.device.Protocol.LAN))

My first question is… is getting the response possible? If so, please explain it to me like I was 4.

Second question is… Is a PUT or POST using the same mechanism possible? I have tried with something like:

sendHubCommand(new physicalgraph.device.HubAction("""PUT //<Path>/?<Params> HTTP/1.1
HOST: <IP:Port>
Content-Length: <calc'd length>
Content-Type: <proper type for content>

""", physicalgraph.device.Protocol.LAN))

But it never seems to be satisfactorily understood by the host.

I am confused and a little frustrated that these questions, which have appeared in this community quite a number of times, are seemingly ignored.

Are they not supported? Does no one at SmartThings know how they’re supposed to work.

Can someone (@Ben, @urman, @tyler, @matthewnohr, @mager, @anybody) address this for us… please.

Yes you can get the response. You can’t explain it like you were 4 though. It’s not simple.

Look at any of the Lan devices and how they trap the response using key phrases like the urn.

Put and post generally have the same outbound mechanisms. Build the packets and transmit. The real difference is on the receiver side.

At least I think that’s how all this works… Lol

Aren’t device types using hubAction? Are you saying sendHubCommand works identically? My experience is that it does not? i.e. ‘parse’ is not called.

1 Like

Look at the foscam connect app

Iapp gets response ands it down to child device.

Where is it?

I think under examples isn’t it?

I looked through all of the samples (user too) and didn’t see it.

Apps not devices


It’s not obvious. If you are sending hub commands from a SmartApp you need so subscribe to the responses with something like this:

subscribe(location, null, lanResponseHandler, [filterEvents:false])

The handler method receives and event like other event handlers, and the description property of the event contains the response. That’s different from a device type, as someone pointed out, which gets the reponses via the parse() method.

1 Like

Apps is where I was looking.

Do you see any of the Lan apps in there? They will have code that’s the same/similar that Bob is pointing out.

Thanks @bflorian, I’ll give this a try as soon as they get the Sim working again.


Hi Bob,

Ok… one step forward.

I have a very simple http server here. When I input this url to the browser:

I get back:

ampOFF command received.

If I then test using the following SmartApp in the sim:

preferences {
	section("When the following is turned on and off...") {
		input name: "master", title: "Which Switch?", type: "capability.switch", required: true

def installed() {

def updated() {

def subscribeToEvents() {
	subscribe(master, "switch.on", onHandler, [filterEvents: false])
    subscribe(location, null, lanResponseHandler, [filterEvents:false])

def onHandler(evt) {

def lanResponseHandler(evt) {
	log.debug "In response handler"
	log.debug "I got back ${evt.description}"

def doHAMB() {
def ip = ""
sendHubCommand(new physicalgraph.device.HubAction("""GET /?ampOFF HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN))

I get back:

2:39:18 PM: debug I got back index:01, mac:0016CBA27305, ip:0A00000C, port:1F90, headers:SFRUUC8xLjEgMjAwIE9LDQpDb250ZW50LVR5cGU6IHRleHQvaHRtbA0KQ29udGVudC1MZW5ndGg6IDI0, body:YW1wT0ZGIGNvbW1hbmQgcmVjZWl2ZWQu
2:39:18 PM: debug In response handler

Which makes perfect sense as the string after ‘body:’ decoded from base64 = ‘ampOFF command received.’

So now if I input the following from the browser:

I get back:


But when using the above test app with the follwoing changes:

def ip = ""
sendHubCommand(new physicalgraph.device.HubAction("""GET /query/info HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN))

I get back nothing. It is as if the ‘lanResponseHandler’ is never called.

I am afraid I still don’t understand why.

@bflorian I am still looking for answers to the above. Would you please help?

Not just the data return issue, but also why I can’t seem to successfully execute a PUT or a POST.

1 Like

I’m trying to figure out the same thing, and am having no luck. I have a rental house with a v2 hub in it. A few days ago the DDNS service on a different device quit working, and I no longer can find the IP the router currently has.

I was hoping to build a quick SA or DT that would allow me to simply send a REST command to a web server that would return the JSON encoded IP. I’ve tried using HubAction, but nothing ever seems to happen. The web server logs show no connection, and parse() never gets called. I would even settle for creating the connection and then manually checking the logs on the receiving end for the IP, but would prefer to get the IP back and display it in the DT or SA.

All of the documentation I’ve found on this site show that this should work, but I’ve found several posts that indicate it was broken by the v2 platform changes last fall.

Is there an alternative to doing what I want to do? Thanks for any insight.


I am in the same boat. My old apps using httpGet() no longer work so I am trying to use sendHubCommand(). Documentation is extremely poor. All I want to do is call a php file passing parameters to it. i.e

Check my implementation for Successfully Integrated Air Quality Monitor "Air Mentor Pro 2" in SmartThings using Raspberry Pi
It sends a php req to my local Raspberry Pi hosting a webpage that collects status from a device. I have a php script receiving the request and sending the answer.