Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
  • 0
vanni177

Hue API in Scenes

Question

Hi I tried to use a Hue API command in my scene, but it's not working.

 

I copied the LUA code from a working Hue VD and modify a bit, as the original is to switch off a Hue.

I'd like to switch "group/0" in Hue-bridge to turn off all hue lights at once. 

 

here is how it looks like and is not working. 

 

I guess the problem is :

    Hue = Net.FHttp(hueIP,huePort)
    response ,status, errorCode = Hue:PUT('/api/'..hueuser..'/groups/0/action', '{"on":'..on..'}')

 

Any help on that is welcome :)

 

Please login or register to see this attachment.

Edited by vanni177

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi Vanni,

 

in scenes you can not use Net.Fhttp. this is working in vd's only. You should use net.HTTPClient() here instead. a sample rest call inside a scene can be:

 

Please login or register to see this code.

 

 

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • Hi Kurtyy,

     

    thanks for the info. Didn't know that. :o

    But actually I'm a little lost with the sample.

    What I want to do is this.

    image.png.80e2687f50f9e2b515b88cf0ca2890b3.png

    Can you help me out with that?

    Thanks a lot and cheers. :)

    Share this post


    Link to post
    Share on other sites
    • 0

    Hi,

     

    You got it working? I am struggling also.

    The message I got:

     

     

    Please login or register to see this attachment.

    Got it working. My example:

     

     local http = net.HTTPClient()
     http:request(("http://192.168.0.20/api/509633ae6ad2cc365051552941c29acc/groups/1/action"), {
        options = {
        method = 'PUT',
        headers = {
            ['Accept'] = 'application/json',
            ['Content-Type'] = 'application/json'
        },
        data = '{"on":false}'
      },})

    Share this post


    Link to post
    Share on other sites
    • 0
  • Inquirer
  • Thank you :) 

    that works well

     

    Edited by vanni177

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×