9

Philips Hue as a virtual module in the Fibaro HC2

by crissxcross20. November 2015

The Philips Hue lights as first of their kind meanwhile enjoy more and more popularity despite their high price. The Smartphone Control is a nice gadget but at the same time a curse as well. The colored pears are nice to be used as “Appcessories”, but who wants to have to look for their smartphone every time they step into a room, only to turn on the light.

Philips had opened the API for the Hue for a while now, so that one is able to integrate the colored pears in various systems. RWE Smart Home showed how to do it (we reported) and integrated the Philips Hue into their home automation.

What would it be like if you were able to integrate the Philips Hue lights into your Fibaro Home Center 2?

Sounds like a nice gadget at first, but at the second glance it is much more than that. Integrated into the Fibaro HC2 as a virtual module, it is possible to address the Philips Hue like a physical hardware component. You can turn it on or off via switch, remote or motion sensor. You can also integrate it into scenes, for instance to get an open window signaled visually.

This is how you integrate the Philips Hue into the Fibaro HC2. Unfortunately it is not suitable for the Fibaro HCL, due to the fact that a LUA Code is necessary.

Create a User on the Philips Hue Bridge

First of all, you need a user name on the Philips Hue Bridge, to be able to address the Philips Hue API with it later on. In order to do that, go to the web surface of the Hue Bridge, via your browser, under the address:

http://<philips-hueip-address>/debug/clip.html

The easiest way for you to find the IP address of the Hue Bridge is via the web surface of your router.

On the web surface of the Philips Hue Bridge, next to the buttons GET, PUT, POST, DELETE, you can find three boxes:

  • URL
  • Message Body
  • Command Response

To create a new user, write the following in the URL line:

http://ip address>/api

Following belongs in the Message Body:

{"devicetype":"test user","username":"newdeveloper"}

Web Surface of the Philips Hue Bridge

Web Surface of the Philips Hue Bridge

Thereby, the user “newdeveloper” is created. Of course, you can name him Fibaro or HeinzHorst as well. Before pressing the button POST, you shortly need to press the (physical) button on the Philips Hue Bridge. After you now pressed POST, you should receive a “success” notification. A Step by Step instruction for the Philips Hue API can be found on “Getting started” as well.

Creating a virtual Module

Fibaro HC2 – creating a virtual module

Fibaro HC2 – creating a virtual module

You can switch to the web surface of your Fibaro HC2 now. On there, you create a new virtual module under “Module” > Add or remove > Add a virtual module. Name the module freely. This module will control a Philips Hue Bulb. Therefore I name my modules Philips Hue Bulb 1 to 3. Assign another room. The field for the IP address and the TCP Port can stay free.

Fibaro HC2 – name a new virtual module

Fibaro HC2 – name a new virtual module

Go to the tab “Advanced” and add a slider.

This slider is later on going to adjust the brightness. Preferably name it “Brightness”, assign “sldBrightness” as ID and select “LUA Code” for the slider.

Fibaro HC2 – Add the slider to the virtual module

Fibaro HC2 – Add the slider to the virtual module

Upload Icon Set

In order for the virtual module to later on receive a matching icon depending on the brightness of the Philips Hue, the next thing you need is the Icon Set. You can download it on here:

Icon Set Lights

Unpack it on your computer after the download. You will find 13 icons in this file. Upload them via the button “change symbol” in numbered order.

Fibaro HC2 – Change the virtual module, icon

Fibaro HC2 – Change the virtual module, icon

As soon as those icons are uploaded, you are going to receive an ID from the Fibaro Home Center. The first icon usually receives the ID 1000, the next the ID 1001 and so on. To make sure that your IDs start at 1000 as well, since you could have uploaded icons before, check it once more. The easiest way to do that is via the Google Chrome Browser or when using Firefox via the developer-tools. With a right-click on the icon > then “examine element” the assigned ID can be found in the source text.

Fibaro HC2 – right-click on Icon

Fibaro HC2 – right-click on Icon

You can find the assigned ID in the source text. You need it in the script.

Fibaro HC2 – Examine element opens the source text and shows the ID of the icon

Fibaro HC2 – Examine element opens the source text and shows the ID of the icon

Slider LUA Code

The earlier added slider is supposed to receive the script now, which adjusts the brightness of the Philips Hue. Since the value of the Philips Hue light for the full brightness is 255, and the slider can only adopt a value of 0-100, we always need to multiply it with 2.55. You can copy the following code into the slider (sldBrightness) like that:

The three values, which have to be adjusted, can be found in the head of the LUA Script.

This is the IP address of your Philips Hue Bridge. I you named your user name other than “newdeveloper” in the first step you need to replace it as well. The value “hueLightID” shows, which Hue Bulb is supposed to be controlled. The starter package of the Philips Hue includes three lights. This means the value in this case could adopt 1-3.

If your Fibaro HC2 did not start at 1000 by assigning IDs to the icons, you might adjust them – beginning at the function:

Fibaro HC2 – inserting of the LUA Codes into the Slider (Brightness)

Fibaro HC2 – inserting of the LUA Codes into the Slider (Brightness)

Main loop LUA Code – Requesting Status

Fibaro HC2 – inserting of the Main Loop LUA Code which requests the status of the Philips Hue steadily

Fibaro HC2 – inserting of the Main Loop LUA Code which requests the status of the Philips Hue steadily

The Main Loop Code is going to update the status of your Philips Hue Bulb steadily, to update the status of the slider, the icon and the information bar. In case you should use the Philips Hue App from time to time, to adjust the brightness, the status slider in the virtual module of the Fibaro HC2 is updated automatically. The Fibaro HC2 gets these information every 3 seconds (Standard, can be changed in the script) from the Philips Hue Bridge. Copy the following script into the field “Main loop”. Here again, you need to adjust the values “hueIP”; “hueUser” and the “hueLightID” in the head of the script.

In case your icons should not start with the ID 1000 and up, you need to change that in the “function getIcon” as well.

This is where the color comes in

Until this point, you have a finished virtual module, which can turn your Philips Hue on and off, as well as dim it. If you now want to change the color in the virtual module as well, you need another slider. Therefore, just add another slider and, for instance, name it “Color”.

Fibaro HC2 – Inserting another slider

Fibaro HC2 – Inserting another slider

You can freely assign the ID. I named it color in this example. Add the following code:

On here, you need to adjust the variables “hueIP”; “hueUser”; and “hueLightID”, just like you had to with the other scripts as well.

Fibaro HC2- inserting the Slider and the LUA Code to be able to vary the color of the Philips Hue

Fibaro HC2- inserting the Slider and the LUA Code to be able to vary the color of the Philips Hue

Now you are not only able to vary the brightness with the virtual module, but also the color. You can address both sliders, even in scenes, and for instance turn on the Philips Hue with the Fibaro Motion Sensor, if motions were recognized. You could change the color of the Philips Hue to a pre-defined color, if for example the window contact recognized an open window.

Fibaro HC2 – Philips Hue can now be used as virtual module in scenes as well

Fibaro HC2 – Philips Hue can now be used as virtual module in scenes as well

Another tip, assign a fixed IP address to the Philips Hue Bridge, therefore you do not have to adjust the IP in the virtual module that often. In case you are using a FRITZ!Box, you can check the field “always assign the same IP address to this device”.

You can also download the virtual module here, and import it into your Fibaro Home Center 2. You have to reload the icon set, since it unfortunately cannot be exported into the virtual modules.

Virtual module – Philips Hue lights

The Philips Hue Bridge is steadily requested via the virtual module

The Philips Hue Bridge is steadily requested via the virtual module

************** Update August 16, 2014 **************

Thank you very much, Simon! He has undergone the virtual module for the Philips Hue a fine tuning.

– Saturation adjustable via slider
– State: on|off can only be affected through the brightness (no more also through brightness)
– IP und TCP Port are read from the module

 

PHILIPS Hue as virtual module – Update with saturation

PHILIPS Hue as virtual module – Update with saturation

This means, the IP address does not have to be changed in the LUA Code directly, but can also be endorsed in the virtual module in the tab “General” under IP Address.

Simon fills the variable “hueIP” with the following order

Thank you, Simon, for the advancement of the virtual module.

You can download the update on here:

Update – virtuelles Modul – Philips Hue Leuchten

Linda translator

This text was translated by Linda

Hi! My name is Linda and I graduated high school with great interest in English language. I help with mein-cleveres-haus.de and translate texts for siio.de in my spare time.

You can read the original in German on siio.de.

About The Author
crissxcross
Hi, I'm crissxcross, qualified IT system electronics. Professionally, I work as a product marketing manager in the Smart Home. And private I am self a Smart Homie :-) If I do not sit in front of the monitor like I photograph and am a big fan of Apple. I am the founder of the SiiO.de blog.
  • Jan
    4. February 2016 at 9:40

    Hi. Great post! When I try to copy the LUA code, a lot of (CSS?) formatting is included in the code. Is there a way to copy the “clean” code?

    Thanks!

  • Jan
    7. February 2016 at 9:25

    Thank you so much for this post! Do you have the LUA codes without all the formatting? It’s a lot of

    font-family: Courier, ‘Courier New’, sans-serif; font-size:……..

    to get rid of :)

  • Andres
    15. April 2016 at 13:47

    Hi, it works correctly, but i have a problem with the app for iPhone, it not change the icon of the bulb when the state change. Can you help me?

  • Alessandro
    26. April 2016 at 16:21

    Hello,

    Still no chance to use Philips Hue with Fibaro HCL?
    Do I have to upgrade do HC2 ?

    Thank you very much

  • Alessandro
    27. April 2016 at 10:18

    Hello,
    Yesterday I wrote a message, that has been deleted.
    I asked if nowadays is there a chance to use Philips Hue with Fibaro HCL, otherwise I have to upgrade to HC2.
    I was sure that it wasn’t offtopic, so I rewrite the question.

    Thank you very much

    Alessandro

    • boomx
      boomx
      9. May 2016 at 15:31

      Hi,

      no, at the moment there is no way to use it. :( Maybe Fibaro puts it in the next firmware-release.

  • Sindre
    11. October 2016 at 22:59

    Hi!

    This post now needs some updates:
    Philips has change the way to get username, you can not make your own username anymore and will have to use a code something like this:
    {“devicetype”: “test user”}

    And get a long random username.

    Also FHttp command doesnt seem to work with HC2 anymore? I only get this error
    [ERROR] 22:52:22: line FHttp:
    [ERROR] 22:52:37: line FHttp:

Leave a Response