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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.