POST + https request in EDGE


What is the proper way to do a https POST request inside of an EDGE driver. I tried to do this:

   local https   = require("ssl.https")
   local _, code = https.request({
      options = {"all"},
      headers = {
         ["Content-Type"] = "application/x-www-form-urlencoded"

I can verify that the post https request is correct using curl, but the request in the driver seems to fail.
What am I missing?


SmartThings has disabled https, dns and public ip on edge. Edge isn’t ready for primetime yet as a viable option to replace groovy unfortunately.

1 Like

Hm… That’s unfortunate. Is there a reason why this is? When will it be turned on? In some ways I’m glad that’s true. This one was a head scratcher.


https absolutely works in Edge drivers; I’ve used it.

I think you were just missing the cosock.asyncify instead of require:

local https = cosock.asyncify "ssl.https"

I didn’t realize they had enabled it. Wonder when they’ll enable the rest

@TAustin Thank you for your post. I should have mentioned that I tried both with asyncify and without. I must have a mistake but I can’t seem to find it. The exact same url works in curl but not in the code. On a related note, it’s very difficult to debug this. All the returns are nil…

Any other deas?


What error are you seeing in the log?

@TAustin I don’t get any errors in the log at all. All return vals are nil and I don’t get a 200 return code…

Is the target receiving the message? Just trying to understand if it’s a problem sending or a problem receiving the response.

@TAustin I can’t tell if the target is receiving since I am calling a REST api. What I mean is that I don’t get anything useful from the https.request call itself. The call completes but the return variables are all nil. At least I think they are.

I noticed that you are including Content-Type header, however you don’t appear to be sending any body data with your message. If the REST api you are using isn’t expecting any, then try removing that header. Otherwise, if you are sending data in the body part of the message, then you should also include a Content-Length header and of course this:

source = ltn12.source.string(sendbody)

If you want, you can send me a direct message with the URL so I can check that. Otherwise, have you tried plugging that exact url into a browser to confirm that it works ok?

EDIT: One other thing, I usually include this header in all requests - body data or not:

Accept = */*

1 Like

Is the URL you are calling on the local LAN or the internet?

Edge drivers only allow local LAN

@TAustin OK. I will give that a try.
@lmullineux Are you sure Edge drivers only allow local LAN? If so, that seems very restrictive. Where is this limitation documented?

Documented, but could be more obviously called out as “ONLY local LAN”.

Edge is only for local device control - there are other paradigm and approaches for internet devices

@csstup Wow that’s pretty annoying, actually. In a groovy DHT you could call external addresses. The functionality has gone backwards in this respect. I suppose the claim will be that it has something to do with security, but it seems to me https requests to outside addresses are secure(?). Also, it would be good if the http request calls would return something saying that the address is not accessible or something instead of just nothing.

Anyhow, thank you for the help.

1 Like

@lmullineux Can you elaborate, please?

Sure, smartthings supports many different device types. Edge is intended only for hub connected devices.

You can build internet connected devices, and smartapps still on the new platforms. Just like you could with groovy, only difference is now you have to host them yourself.

If you really want to use edge (although this is not what Samsung intended) you can use a proxy installed on a device on your network (e.g a raspberry pi) to get your requests out onto the internet. @TAustin had some software that you can use

@lmullineux I see what you mean. In my case I am trying to add functionality to the Flair vents and pucks. I had it all working with groovy and I am now porting it to Lua. I suppose I would have had to choose to create a Cloud Connected Device and implement all the auth stuff. That’s a lot of work for just 3 devices in my case. It’s more work than just creating an Edge device, since porting from groovy is proving to be pretty easy. It’s still a little unclear as to why an Edge device cannot access the outside world. Is it really a security concern? As you point out, I will have to end up creating a simple “API proxy” that sits inside my LAN and translates from the Edge device to the API…I will probably just write it in php. Simple enough. A little annoying, but it will still be less complexity than supporting a “Connected & Secure Cloud” using Schema, etc. That route really seems to be for more of a professional solution rather than the part time software person.