sendHubCommand and POST?

(Convinced ST will never be unbroken…) #1

I have been successful sending local GET requests with the following:

def ip = “"
def pathorparams = “?doSomethingLikeThis"
def deviceNetworkId = “1234"
sendHubCommand(new physicalgraph.device.HubAction(””“GET /$pathorparams HTTP/1.1\r\nHOST: $ip\r\n\r\n””", physicalgraph.device.Protocol.LAN, “${deviceNetworkId}”))

But for the life of me I am unable to work out the structure for a POST. Would the experts at large shine a little light on this for us.

(Morgan) #2

I’ve very curious about this as well, what GET requests have you been able to get replies back from?

(Convinced ST will never be unbroken…) #3

Honestly, I don’t care about the response. I am sending GET requests to HAM Bridge to execute commands from it, but I have other devices that require POST and PUT. I suppose I can have HAM Bridge do those, and trigger them with a GET; I was just hoping to eliminate the extra hop.

(KATTI) #4

how does the code written in my smartthings account will work with my smartthings sensors and hub???which is the triggering point???please reply me as early as possible???

(Ben Edwards) #5

@KATTI - I would encourage your to check out the following resources in the SmartThings Documentation:

An Introduction to the IDE

Building Your First SmartApp

And a general overview of SmartApps

If you still have questions, these docs should help you write them up in a way that helps the community to help you. Failing that, you can always contact


(Convinced ST will never be unbroken…) #6

Still struggling with this and would really appreciate some guidance. Is there something borked with sending a POST from sendHubCommand? Or just something odd about it I should know?

When sending from curl:

curl --data "mode=1&fan=0&heattemp=50&cooltemp=85"

My Venstar ColorTouch turns on (heat mode=1).

But when I execute:

def postHTTP() {
def body = """mode=${settings.mode}&fan=${}&heattemp=${settings.heattemp}&cooltemp=${settings.cooltemp}"""
def length = body.getBytes().size().toString()
def venstar = "${settings.server}"
sendHubCommand(new physicalgraph.device.HubAction("""POST /control HTTP/1.1
HOST: ${venstar}
Content-Length: ${length}
Content-Type: application/x-www-form-urlencoded

""", physicalgraph.device.Protocol.LAN, "${venstar}"))

I get the following in the log, but nothing happens on the thermostat.

8:31:34 AM: debug Executing POST /control HTTP/1.1
Content-Length: 36
Content-Type: application/x-www-form-urlencoded

on Home Hub via sendHubCommand

Now if I send the above curl command to another terminal on my LAN I get:

POST /control HTTP/1.1
User-Agent: curl/7.30.0
Accept: */*
Content-Length: 36
Content-Type: application/x-www-form-urlencoded


And if I direct the sendHubCommand to that terminal I get:

POST /control HTTP/1.1
Content-Length: 36
Content-Type: application/x-www-form-urlencoded


I have even gone so far as to include the Accept and User-Agent header fields in the call to sendHubCommand, but nothing has worked when attempting to POST to the thermostat.

Local Network HTTP/s Or Internet HTTPS with Authentication
(Aaron) #7

Poking at an old thread, I know. @scottinpollock, how far did you get with that Venstar t-stat?

(Convinced ST will never be unbroken…) #8

Works like a charm; no auto discovery though. Check it out HERE.

(Aaron) #9

Thanks @scottinpollock.

. . . . means you tried but couldn’t get a Service Manager SmartApp to work or didn’t bother to try?

Also, according to the ST docs, it seems like ST intends, in addition to discovery, that a Service Manger SmartApp handle the communication and the Device Handler does the parsing and such. However, it looks like your Device Handler is taking care of the POSTs and GETs (communication). So, I think, that leaves discovery that would be handled by the Service Manager, if there was one.

So, if you don’t mind, and you did try, what problems did you encounter trying to create a Service Manager? Did you find the Venstar API adequate?

(Convinced ST will never be unbroken…) #10

Looked at it. Documentation sucked (still does), and no one was willing to help. It works well as it is, and that was all I needed.

BTW, the Venstar API is great, but completely local. Frankly, I use it more (called from HAM Bridge) than the SmartThings integration as I still can’t count on SmartThings to reliably execute critical tasks (in this case preventing pipes from freezing).

(Aaron) #11

@scottinpollock, yea, the docs in this area seem to leave a lot to be desired. Also, unless I’m missing something, there are no ST-published handlers for LAN-connected devices to use as examples.

. . . and, if I haven’t used up my allotment of stupid questions. . . . the Venstar API uses JASON formatting for GETs but the POSTs are URL-encoded. Do you know why that is?

Thanks again!

(Convinced ST will never be unbroken…) #12

Nope. My guess is that most usage for control/settings would only be a few name/value pairs versus the info get returns can be far more comprehensive.

(Aaron) #13

I thought that might be the case but I am a relative newb so I was afraid I may be missing some key concept. Thanks again.