LIFX Developer Zone

FIBARO Home Center Integration

Dear LIFX Experts,

Did any of you successfully integrated the LIFX into the Fibaro Home Center 2? So that it is possible to control the LIFX from the HC2? I would appreciate your help.

Cheers,
Alex

I’m not aware of anyone who has done an integration with FIBARO. I’m not sure it is even possible as I thought that they could only do Zwave or Zigbee based devices. I’d be happy to be proven wrong though.

Dear Daniel,

The FIBARO Home Center runs with LUA scripting language.

The Philips Hue light offers for instance an API. Consequently several people programed the LUA code to fully integrate the Philips Hue into the FIBARO (e.g.: step by step instruction how to integrate Philips http://siio.de/lichtschatten/philips-hue-als-virtuelles-modul-im-fibaro-hc2/ ).

I would like to buy several LIFX, but if only the Philips light can be controlled with an API from the FIBARO I will need to invest into the Hue. Maybe there is a solution to get LIFX (what I like most) controlled by FIBARO . This would be great! Please consider that the FIBARO HC is quite popular and powerful.

Cheers,
Alex

I also want to add my interest to this. I really would like to see the LIFX implemented to my Fibaro system. I have no experience with code, but can work with simple strings etc. Fibaro works with several wifi-enabled devices (cameras, tv’s etc.), so why not LIFX!?

If it uses Lua scripting then it is most likely possible to integrate with LIFX, however only a few of us know Lua and all of us are quite busy. None of us have the ability to test as we done have any FIBARO equipment. If someone is going to make it then it will most likely have to be a third party.

That said I’m here as developer support and I’m happy to help you as much as possible to get things going. My suggestion would be to start with the HTTP API. You’ll need to use the Lua socket HTTP library to make the requests.

Thank you for your reply!

I will have a look at this in the holiday. If I get somewhere I’ll let you know :wink:

It’s not really that hard to talk to the LIFX API via scenes in Fibaro. Unfortunately, it’s not currently possible (AFAIK) to do via virtual devices, since virtual devices can’t communicate via HTTPS (which is a requirement for using the LIFX API).

If you can’t use HTTPS to talk to the API it might be possible to use the LAN Protocol, provided that the FIBARO device is on the same network as the bulbs. It is a little more complex though, but if you have any questions feel free to ask.

Try this link below. you will have to translate the page. let me know if this works for anyone.

http://www.domotique-fibaro.fr/index.php/topic/4293-hc2-et-lifx/

Thank you for the link.
Unfortunately it does not work.
Maybe one of the experts can explain the two lines that create errors:

1: "http:request('https://api.lifx.com” What exactly do I need to write behind?

2: “[‘Authorization’] =” What exactly do I need to write behind. I just copied the token and it did not work.

The original code from the above quoted link:

local http = net.HTTPClient()

http:request(‘https://api.lifx.com/v1beta1/lights/group%3ASchlafzimmer/power.json?selector=group%3ASchlafzimmer&state=on’, {

options = {

    method = 'PUT',

    headers = {

        ['Authorization'] = 'Basic Y2YxM2FjODJkZDcyYjRmZmZiYTAwOGQ4ZDUxMTE2ZWQ4ZTdlMTE0ZTJjYWU4YWMjI5NzUwMTEyMjBmMTk0Nzo='

    }

},

success = function(response) fibaro:debug(response.data) end,

error = function(err) fibaro:debug("Error: " ..err) end

})

PS: HTPPS is supported in Scenes in Fibaro (but not in VD’s). So if somebody can share the exact LUA code for a LIFX HTTPS request all Fibaro users could get it to work :smile:

local http = net. HTTPClient () http : request ( 'https://api.lifx.com/v1/lights/label:Light1/state.json?selector=label:Light1&power=on&brightness=0.7', { options = { method = "PUT", headers = { ['Authorization'] = 'Bearer cce26ealkadjas3749264hfjshksdhfksdfj37467648nnkjh872364adjlkajd3849764' } }, success = function (response) fibaro: debug (response. data) end, error = function (err) fibaro: debug ("Error:" .. err) end })

1 Like

Sorry guys all this is fairly new to me. I don’t know if I’m even doing it right when trying to control the lifx bulb on Fibaro. I am trying to create a virtual device (lifx bulb) and it does not take any of the code. I cannot add any code to scenes. Can anyone point me in the right direction or even send me a link to a video (this would really help me) thanks

Hi, anyone successfully integrate lifx into fibaro?

I get a positive response from this. will look further into these settings in the following days.

With connected power:
[DEBUG] 21:27:58: {“results”:[{“id”:“d073d5010870”,“label”:“Lifx”,“status”:“ok”}]}

Disconnected power:
[DEBUG] 21:32:53: {“results”:[{“id”:“d073d5010870”,“label”:“Lifx”,“status”:“timed_out”}]}

Tested it with a scene, will test it as a virtual device later this week.

Rewrote the script a bit, makes it a bit more usable and configurable in my opinion. It works nicely, at least on and off are usable in the scenes. Also brightness works.

local http = net. HTTPClient ()

–The variables below can be modified
local Bauth = ‘c355cb7b4b2b9b6280ab309911725d4696985543f82da25a45e7a8e01d6dc043’ --Lifx authentication ID
local Bname = ‘Lifx’ --Bulb name
local power = ‘on’ --ON or OFF
local brightness = ‘0.1’ --0.1 - xxx

–The script below this line should not be edited
local url1 = 'https://api.lifx.com/v1/lights/label:'
local url2 = '/state.json?selector=label:'
local url3 = '&power='
local url4 = '&brightness='
local Bbear = 'Bearer ’

http : request ( url1 … Bname … url2 … Bname … url3… power … url4 … brightness, {
options = {
method = “PUT”,
headers = {
[‘Authorization’] = Bbear … Bauth
}
},
success = function (response) fibaro: debug (response. data) end,
error = function (err) fibaro: debug (“Error:” … err) end
})

Guys,
Can someone with Fibaro verify if this solution works. I am going to invest in the Fibaro HC 2, would be awesome to know as I already have 12 lifx bulbs.

Thanks in advance.

Cheers!!!

vishix,

I have confirmed this is working. in my code i added color. just change the color and brightness to your liking. make sure you set the scene to do manual not automatic in HC2.

–[[
%% properties
%% events
%% globals
–]]
local http = net. HTTPClient ()

local bauth = ‘xxxxxxxx’ --Lifx authentication ID
local Bname = 'Desk’
local power = 'on’
local brightness = '0.5’
local color = ‘random’

local url1 = 'https://api.lifx.com/v1/lights/label:'
local url2 = '/state.json?selector=label:'
local url3 = '&power='
local url4 = '&brightness='
local url5 = '&color='
local Bbear = 'Bearer ’

http : request ( url1 … Bname … url2 … Bname … url3… power … url4 … brightness … url5 … color, {

options = {
method = “PUT”,
headers = {
[‘Authorization’] = Bbear … bauth
}
},
success = function (response) fibaro: debug (response. data) end,
error = function (err) fibaro: debug (“Error:” … err) end
})

this is another scene for powering it off.

–[[
%% properties
%% events
%% globals
–]]

–[[
%% properties
%% events
%% globals
–]]
local http = net. HTTPClient ()

local bauth = ‘xxxxxxxx’ --Lifx authentication ID
local Bname = 'Desk’
local power = ‘off’

local url1 = 'https://api.lifx.com/v1/lights/label:'
local url2 = '/state.json?selector=label:'
local url3 = '&power='
local Bbear = 'Bearer ’

http : request ( url1 … Bname … url2 … Bname … url3… power, {

options = {
method = “PUT”,
headers = {
[‘Authorization’] = Bbear … bauth
}
},
success = function (response) fibaro: debug (response. data) end,
error = function (err) fibaro: debug (“Error:” … err) end
})

Hi
looks great.

but do you know how to get the variable (response. data) out the ‘function’ http : request

so after })

like to hear from you!

How would you trigger your lifx scene in hc2? Please share!!