Jump to content
C4 Forums | Control4

Sending HTTP PUT requests from LUA


ziocan

Recommended Posts

Hi there,

I am trying to write a small driver that allows me to call the LIFX smart bulbs API to activate/deactivate light scenes.

Unfortunately, the damn API wants to receive PUT requests.  In the driverworks documentation I only see support for GET and POST.

Does anybody know if there's a way to send a PUT request from LUA code in a driver? Maybe someone has some code to share? :-)

Other than invoking curl on the controller, of course...

 

Thanks in advance,

Rick

 

Link to comment
Share on other sites


Thanks, this was easier than expected!

 

function ActivateScene (Scene)
   local http_headers = {}
   http_headers["Authorization"] = "Bearer " .. Properties["LIFX Cloud token"]
   URL = "https://api.lifx.com/v1/scenes/scene_id:" .. Scene .. "/activate"
   C4:urlPut(URL, "", http_headers)
end

 

Link to comment
Share on other sites

  • 1 year later...
  • 7 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...