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

Control of Hue lights using virtual devices


automationfan

Question

Looking at the Hue API, it seems to me that one should be able to control Hue lights using a virtual device and some LUA code to post over http.

Please login or register to see this link.

I'm going to play around and try to get this working (based on some of the Sonos examples) - in the meantime I'm sure there are other more development minded people on this board who might be able to get a quicker result - so I have posted the link to the API test examples.

I'll update if I get anywhere...

Link to comment
Share on other sites

Recommended Posts

  • 0

automationfan, you got ready script on forum created by user

Link to comment
Share on other sites

  • 0
  • Inquirer
  • I got the impression that this script required a third party web sever which I don't have?

    I wanted to control the lights by talking directly to the bridge?

    Link to comment
    Share on other sites

    • 0

    The best way, is fibaro give choice for the slider to set value. (1 to 99 or some color)

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • OK - a few people have shown an interest in this.

    This is a simple way to control Hue bulbs directly using virtual devices, without needing a web server or any other software.

    1. Register a new user on the bridge API

    You press the button on the hue bridge and then use the clip debugger to POST to the bridge.

    Instructions are on this page:

    Please login or register to see this link.

    I created a user called 'automation1' for this (for some reason you can't use 'fibaro')

    2. Create a virtual device with the following LUA code (depending on what you want to do):

    -Change the IP below to that of your Hue Bridge.

    -Change the URL to include your username (I used 'automation1')

    -The number 8 in the URL is the reference to light 8 on the bridge - so change this depending on what light you want to control.

    Turn light on - warm white:

    HueGtw = Net.FHttp("192.168.1.11",80)

    HueGtw:PUT('/api/automation1/lights/8/state', '{"on":true, "sat":255, "bri":255,"ct":400}')

    Turn light off:

    HueGtw = Net.FHttp("192.168.1.11",80)

    HueGtw:PUT('/api/automation1/lights/8/state', '{"on":false}')

    Change colour:

    HueGtw = Net.FHttp("192.168.1.11",80)

    HueGtw:PUT('/api/automation1/lights/8/state', '{"on":true, "sat":255, "bri":255,"hue":60000}')

    All the various parameters are documented here:

    Please login or register to see this link.

    I'm sure there are cleverer ways to do this, but for me this provides a simple and effective control via virtual devices, and can be included in scenes etc for effective integration of Hue lighting with the HC2.

    Hope this is useful for someone.

    Paul

    Link to comment
    Share on other sites

    • 0

    Thanks, i'll try this!

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    [ Added: 2013-09-09, 20:46 ]

    It works

    Please login or register to see this image.

    /emoticons/default_laugh.png" alt=":lol:" />

    If you can do this with an sq blaster, would be fabulous!!!!

    Great work

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Link to comment
    Share on other sites

    • 0

    it works great...thankyou...

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    con can i get value of slider variable???

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Glad it was useful

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    The next thing I would like to do is create a scene can tell when a Hue bulb changes state to trigger other devices - this was I can use the Hue Geofencing whichworks rather well (Fibaro seems to randomly switch my lights on when I'm already at home..>)

    [ Added: 2013-09-14, 11:58 ]

    Got the slider working to adjust the colour in the virtual device:

    Please login or register to see this code.

    Works really well!

    Link to comment
    Share on other sites

    • 0

    and...finally if can i help this is code lua slider (i add 2 slider) for intensity of hue..

    HueGtw = Net.FHttp("192.168.1.254",80)

    vHue = _sliderValue_ * 2.55

    HueGtw:PUT('/api/automation1/lights/3/state', '{"on":true,"bri":'..vHue..'}')

    now with a virtual button on off and 2 slider it can possible full control of bulbs...

    Link to comment
    Share on other sites

    • 0

    Excellent! I have been looking for a way to make Hue and Fibaro work together. This seems like a good solution. Keep up the great tips and tricks :->

    Link to comment
    Share on other sites

    • 0
    Guest shapa

    Some add ons:

    Alarm mode (pulsing) for 30sec:

    HueGtw = Net.FHttp("172.16.1.62",80)

    HueGtw:PUT('/api/automation1/lights/4/state', '{"on":true, "alert":"lselect"}')

    Alarm mode (one pulse)

    HueGtw = Net.FHttp("172.16.1.62",80)

    HueGtw:PUT('/api/automation1/lights/4/state', '{"on":true, "alert":"select"}')

    Colorloop

    HueGtw = Net.FHttp("172.16.1.62",80)

    HueGtw:PUT('/api/automation1/lights/4/state', '{"on":true, "effect":"colorloop"}')

    ColorLoopOff:

    HueGtw = Net.FHttp("172.16.1.62",80)

    HueGtw:PUT('/api/automation1/lights/4/state', '{"on":true, "effect":"none"}')

    Link to comment
    Share on other sites

    • 0
    Guest cedriclocqueneu

    Great ! Thank you for this tips, it's really better without need of an external server !

    And it's really fast

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Link to comment
    Share on other sites

    • 0

    Hi,

    I cannot make this code for controlling the brightness work:

    HueGtw = Net.FHttp("192.168.1.254",80)

    vHue = _sliderValue_ * 2.55

    HueGtw:PUT('/api/automation1/lights/3/state', '{"on":true,"bri":'..vHue..'}')

    Has anyone had succes with this?

    I now have an on and off button as well as a slider to control the color thank to some of the other code posted to this thread

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    Link to comment
    Share on other sites

    • 0
    Did you register automation1 as devellopper in your hue gateway

    Yes, all the other Lua code you guys have been posting works flawlessly - just not the above mentioned "dimmer" slider

    Until i can get the slider working, I've made a five button dimmer with 20% increase of brightness between each button. It's not as sleek though

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    I have solved my brightness slide "issue".

    I do not know if it is a problem with my HC2 in particular (maybe european standard symbols or something), but I had to change a . (punctuation mark) into a , (comma) in the code:

    HueGtw = Net.FHttp("192.168.1.254",80)

    vHue = _sliderValue_ * 2.55

    HueGtw:PUT('/api/automation1/lights/3/state', '{"on":true,"bri":'..vHue..'}')

    Mine is now:

    HueGtw = Net.FHttp("192.168.1.254",80)

    vHue = _sliderValue_ * 2,55

    HueGtw:PUT('/api/automation1/lights/3/state', '{"on":true,"bri":'..vHue..'}')

    Just a heads up if anyone else encounters this problem

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

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