I just covered the topic in a group on Facebook, and might as well cover it here as well so it’s public also to non-swedes.

The question was how to control the Hue lights from scripts. There is a requirement to use a magic Id number to do this. In fact, there are actually two.

Instaling the Hue function in HC2

First you need to install the Hue plugin to have the HC2 even talk to Hue. This guide is very straight forward so no point repeating the same content again.

1.Enable Hue devices in scenes using blocks

What is enormously annoying is that the Hue plugin cannot be used in scenes that you build using blocks. For this, you need to create a Virtual Device.

There is one that looks very competent, but which was developed way after I installed my setup. Feel free to test it- HERE.

My picture is from the version I have installed but in any case you need to find the hueLightID as per my picture below:

That Id is actually rather straight forward. It’s the index number found in the Hue mobile app. Chose the cogwheel (settings) and scroll down to the About option.

2. Addressing the Hue lamps from own LUA code

In your own LUA scripts, you use the Id of the Hue plugin per lamp and not the Id of the lamp a per the Hue index. Hoover the wrench with the mouse and then you see in the URL in the bottom left cornet the Id. In this case 74.

I might just as well provide you with a small piece of LUA that I used to create a Scene for a Walk In Closet. I have installed a door sensor on the door and there is a Hue lamp in there. I want the lamp to turn on when the door is opened, and turn off as soon as the door is closed. You already know that the lamp is Fibaro device Id 74. The Door sensor is device 236.

Script called “Turn ON WiC light”

–[[
%% properties
236 value
%% weather
%% events
%% globals
–]]

local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(236, “value”)) > 0 )
or
startSource[“type”] == “other”
)
then
fibaro:call(74, “turnOn”);
fibaro:call(74, “changeBightness,216”);
fibaro:call(74, “changeHue,45853”);
fibaro:call(74, “changeSaturation,61”);
end

Script called “Turn OFF WiC light”

–[[
%% properties
236 value
%% weather
%% events
%% globals
–]]

local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(236, “value”)) == 0 )
or
startSource[“type”] == “other”
)
then
fibaro:call(74, “turnOff”);
end

Come to think of it, I guess these could be merged to one and the same, right?

Thanks for rating this! Now tell the world how you feel - .
How does this post make you feel?
  • Excited
  • Fascinated
  • Amused
  • Bored
  • Sad
  • Angry