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
 Share

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

I have made two virtual devices and added the LUA code to control my hue bulb and living colors.

I have also got a LED strip that is controled by a Fibaro RGB Controller.

Now I would like to make a scene to change the color of all lights, for example to blue.

The first thing I tried was to add the LUA code directly in the scene, but this doesn't work. Can somebody tell me why?

My workaround is that I'm using a code now that controls the buttons/sliders I made in the virtual devices. Now the lights go on, and I just need to figure out the correct slider settings.

update: I haven't figured it out yet. This code turns the lights on, but doesn't change the color.

How do I use setSlider? What are the two variables?

-- HUE Bulb (11)

fibaro:call(11, "pressButton", "1");

fibaro:call(11, "setSlider", "1", "70");

-- HUE Living Colors

fibaro:call(10, "pressButton", "1")

fibaro:call(10, "setSlider", "1", "70");

-- LED Strip

fibaro:call(12, "startProgram", "6")

Link to comment
Share on other sites

  • 0

I want to check whether a hue bulb is on or off, and then store this in a global variable.

The get command displays a lot of information about the bulb's state. Is there a way to filter the string "on": true / "on": false?

Something like:

Please login or register to see this code.

On the following website someone did something similar with Apple script.

Please login or register to see this link.

How can this be done with lua?

[ Added: 2013-11-08, 13:55 ]

I have made some progress.

For testing purposes I created a virtual device with the following lua code:

Please login or register to see this code.

Debug displays the following:

Please login or register to see this code.

However, when I use the GET command to display the state of a particular bulb, I get no response.

I used the following lua code:

Please login or register to see this code.

Debug gives no response.

With the following code:

Please login or register to see this code.

I get the following debug response:

Please login or register to see this code.

That response is correct because I have no bulb with id 0.

Why don't I get a response from bulb 1, and also not from my other bulbs?

Please note: I can switch these bulbs on and off with a virtual device, and with the API Debug tool I get a normal response about the bulb's state.

Link to comment
Share on other sites

  • 0
Guest shapa

figaro:call(297, "setSlider", "3", "28");

it works fine for me (yellowish tone).

Link to comment
Share on other sites

  • 0

Thanks Shapa, it works now. I entered the wrong sliderID (the number from the IDname "slider1"). Where can I find the number 3?

Link to comment
Share on other sites

  • 0

It looks like the hue api only accepts rounded numbers. Lua code snippets below are working for me.

Right slider for brightness

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

vHue = math.ceil(_sliderValue_ * 2.55)

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

Slider for colortone

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

vHue = math.ceil(_sliderValue_ * 3.47 + 153)

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

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.

 Share

×
×
  • Create New...