Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Hue API in Scenes


vanni177

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
Link to comment
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.

 

 

Link to comment
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. :)

    Link to comment
    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}'
      },})

    Link to comment
    Share on other sites

    Join the conversation

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

    Guest
    Answer this question...

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