LIFX Support

Compatibility (hardware, devices and OS)
superczar
Posts: 90
Joined: Wednesday 14 January 2015 13:08
Target OS: Raspberry Pi
Domoticz version:
Location: India
Contact:

LIFX Support

Post by superczar » Wednesday 14 January 2015 15:05

Is it possible to add LIFX support ?
I am working on integrating the different interfaces I need to use for my house through Domoticz but missing out on LIFX and Wemo at the moment

superczar
Posts: 90
Joined: Wednesday 14 January 2015 13:08
Target OS: Raspberry Pi
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar » Tuesday 20 January 2015 15:27

Solved - In case anyone is interested, i can provide a detailed answer
There are multiple LIFX control libraries available on the net
I fiddled with a Perl library but finally got a reliable solution with lifx-python
Its far from perfect but I could add the LIFX as a dummy switch and now have easy on/off toggles as well as color scenes under scenes

pvm
Posts: 857
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: Stable
Location: NL
Contact:

Re: LIFX Support

Post by pvm » Wednesday 21 January 2015 13:52

Lease state in the wiki
Synology NAS, PI3, ZWave, Xiamo zigbee devices, BTLE plant sensor

Pi314
Posts: 4
Joined: Friday 23 January 2015 3:26
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 » Friday 23 January 2015 10:06

superczar wrote:Solved - In case anyone is interested, i can provide a detailed answer
There are multiple LIFX control libraries available on the net
I fiddled with a Perl library but finally got a reliable solution with lifx-python
I like to use Domoticz, It's very usefull for me. But one thing is missing, the LIFX intégration.
I'm very interested to receive the procedure to implement LIFX.
Thanks,

superczar
Posts: 90
Joined: Wednesday 14 January 2015 13:08
Target OS: Raspberry Pi
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar » Friday 23 January 2015 11:18

Created a basic wiki page with steps

http://www.domoticz.com/wiki/LIFX

Pi314
Posts: 4
Joined: Friday 23 January 2015 3:26
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 » Sunday 25 January 2015 23:12

Great, It's work fine.
One thing is missing it's the possibility to access the bulbs individually

User avatar
Derik
Posts: 1803
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: LIFX Support

Post by Derik » Sunday 25 January 2015 23:15

Nice..
Only are these better then a HUE?

Very expensive bulbs....?
The reason for that?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups

superczar
Posts: 90
Joined: Wednesday 14 January 2015 13:08
Target OS: Raspberry Pi
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar » Monday 26 January 2015 6:59

Pi314 wrote:Great, It's work fine.
One thing is missing it's the possibility to access the bulbs individually
You can change the name of the bulbs on your network to LIFX1, LIFX2 and so on after which you should be able to call individual bulbs
Nice..
Only are these better then a HUE?
The bulb hardware is better than HUE - 17 W vs 9 W so significantly brighter
Also, the ability to manage saturation independently allows for a far better control on the light spectrum

The official software for the HUE is however far better , the LIFX team has really botched up the apps

User avatar
Derik
Posts: 1803
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: LIFX Support

Post by Derik » Monday 26 January 2015 19:56

Do i need other hardware?
Or only a bulb?

The best place to buy?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups

Pi314
Posts: 4
Joined: Friday 23 January 2015 3:26
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 » Tuesday 27 January 2015 0:32

superczar wrote:
Pi314 wrote:Great, It's work fine.
One thing is missing it's the possibility to access the bulbs individually
You can change the name of the bulbs on your network to LIFX1, LIFX2 and so on after which you should be able to call individual bulbs
I don't see where I can insert in the scripts the name or mac adr. of the bulbs.
When I execute example_intro.py :
at lights = lifx.Lifx() : it's give the adr. of one bulb
at print(lights.get_colours()) : it's give the parameter of same bulb
at print(lights.get_labels()) : it's give me the name of all bulbs

So I will continue to investigate.
Derik wrote:Do i need other hardware?
Or only a bulb?

The best place to buy?
You can check new features will come: http://support.lifx.co/hc/en-us/article ... X-2-0-apps
The LIFX bulbs are WIFI devices and there is no need of bridge or something like that. They join an exiting WIFI network. It's very easy to install.

You can buy directly at http://store.lifx.co/ but you risk to pay customs fee. You have also in NL http://www.coolblue.nl/

mattc
Posts: 8
Joined: Wednesday 25 February 2015 12:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

LIFX Support

Post by mattc » Wednesday 25 February 2015 21:36

New user of Domoticz with a lifx bulb... I've been playing with the new cloud api and have managed to successfully setup a dummy dimmer that works flawlessly.

I've created a dummy switch based on lightwaverf called Lifx and the following lua script (named script_device_Lifx.lua) will allow the control of on/off & dimming:

Code: Select all

commandArray = {}

DomDevice = 'Lifx'
lifxlabel = '<INSERT THE LABEL OF THE BULB YOU WANT TO CONTROL HERE>'
apikey = '<INSERT YOUR OWN API KEY HERE>'

 if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then
   print ("Turning off " .. DomDevice);
   runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/power.json?state=off";
   os.execute(runcommand);
   return commandArray
   elseif(devicechanged[DomDevice]=='On') then
   print ("Turning on " .. DomDevice);
   runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/power.json?state=on";
   os.execute(runcommand);
   return commandArray
   else
   DomValue = (otherdevices_svalues[DomDevice]);
   end
   CalcValue = DomValue / 31.25;
   print ("Dimming "  .. (DomDevice) .. " to " .. (CalcValue) .. " ");
   runcommand = "curl -H \"Authorization: Bearer " ..
(apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/color.json?color=brightness:" .. (CalcValue) .. " ";
   os.execute(runcommand);
 end
return commandArray


It's pretty crude, but works a treat.

You'll need to get your own api key from chendo @lifx in order to use this functionality. See here: https://github.com/chendo/lifx-http/iss ... t-72760322

I'd like to take this further & implement a colour wheel... is there any way of creating a dummy switch with a colour wheel in domoticz? Failing this is there any decent documentation to allow me to write my own hardware device?

mattc
Posts: 8
Joined: Wednesday 25 February 2015 12:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc » Thursday 26 February 2015 0:43

Added the above to the wiki :)

Pi314
Posts: 4
Joined: Friday 23 January 2015 3:26
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 » Sunday 08 March 2015 13:21

Now is possible to generate your own api key (token) yourself by logging into https://cloud.lifx.com/ and going to <your email> -> Settings.

@mattc
They are some typo error ;-) , corrected lines:

runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabe) .. "/power.json?state=off";
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/power.json?state=on";
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/color.json?color=brightness:" .. (CalcValue) .. " ";

in the wiki:
domoticz/scripts/lua/script_device_Lifx.lua

mattc
Posts: 8
Joined: Wednesday 25 February 2015 12:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc » Thursday 19 March 2015 21:18

that's weird, I just copy pasted my working code. Thanks for correcting it.

I'd love to see a native hardware device for lifx in domoticz using the api, I'm sure it could be a quick adaptation of the Hue stuff. I had a quick look but looks too involved for me :(

phitar
Posts: 14
Joined: Sunday 29 March 2015 20:07
Target OS: Raspberry Pi
Domoticz version: 2.2436
Location: Switzerland
Contact:

Re: LIFX Support

Post by phitar » Sunday 29 March 2015 20:14

Wonderful being able to include the LIFX lights ! Thank you so much.

2 minor points:
I had an issue with Lamp Names including spaces. Removing them or replacing them with %20 enabled the scripts.
The typos are still present, missing ¨ after the XPUT parameter in the wiki.

l00pz
Posts: 40
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz » Wednesday 01 April 2015 12:36

I would also like to control the LIFX lights with Domoticz, but I`m unable to get them working.. I think it has something to do with me using the wrong script, but where do I need to put the " that is not present in the Wiki according to the last post?

Is the correct line: runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabe) .. "/power.json?state=off";
Or is it: runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT "https://api.lifx.com:443/v1beta1/lights/label:" .. (lifxlabe) .. "/power.json?state=off";

phitar
Posts: 14
Joined: Sunday 29 March 2015 20:07
Target OS: Raspberry Pi
Domoticz version: 2.2436
Location: Switzerland
Contact:

Re: LIFX Support

Post by phitar » Thursday 02 April 2015 9:40

I thought I had corrected it in the wiki and can't seem to find a difference with what I have.
The log file may give you clues about what's wrong.
The problem I kept on having is the cut&paste function removed some " from the script, specifically those before " ..(lifxlabel) .. "
Here is the script I am using and that is working for me.
Do you LIFX devices have very simple names ?



commandArray = {}

DomDevice = 'DEVICE NAME'
lifxlabel = 'LIFX LABEL'
apikey = 'LIFX API KEY'

if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
print ("Turning off " .. DomDevice .. " named " .. lifxlabel);
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: ..(lifxlabel) .. "/power.json?state=off";
os.execute(runcommand);
return commandArray
elseif(devicechanged[DomDevice]=='On') then
print ("Turning on " .. DomDevice .. " named " .. lifxlabel);
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: ..(lifxlabel) .. "/power.json?state=on";
os.execute(runcommand);
return commandArray
else
DomValue = (otherdevices_svalues[DomDevice]);
end
CalcValue = DomValue / 31.25;
print ("Dimming " .. (DomDevice) .. " to " .. (CalcValue) .. " ");
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/color.json?color=brightness:" .. (CalcValue) .. " ";
os.execute(runcommand);
end
return commandArray

l00pz
Posts: 40
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz » Thursday 02 April 2015 20:44

I created a new script, but I keep getting errors in the Logviewer:

2015-04-02 20:39:30.113 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:39:30.128 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:39:30.163 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:39:30.178 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:39:30.213 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.220 Hardware Monitor: Fetching data (System sensors)
2015-04-02 20:40:00.230 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.253 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.290 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.317 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.352 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.460 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.453 (E Thermostaat) Thermostat (E Thermostaat)
2015-04-02 20:40:01.008 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:00.465 (E Thermostaat) Temp (E Thermostaat)
2015-04-02 20:40:01.032 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:01.281 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:01.291 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:01.286 (Weather Underground) UV (Unknown)
2015-04-02 20:40:01.305 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:01.319 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:01.312 (Weather Underground) General/Visibility (Unknown)
2015-04-02 20:40:02.687 Error: .../dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua:10: unexpected symbol near '?'
2015-04-02 20:40:02.679 (Dommoticzlifx) Lighting 5 (Domoticzlifx)
2015-04-02 20:40:03.340 Executing script: /home/pi/dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua
2015-04-02 20:40:03.350 Error: Error executing script command (/home/pi/dev-domoticz/scripts/lua/script_device_Domoticzlifx.lua). returned: 32256

My script contains the following rules:

Code: Select all

commandArray = {}

DomDevice = 'Domoticzlifx'
lifxlabel = 'Woonkamer'
apikey = '**'

if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
print ("Turning off " .. DomDevice .. " named " .. lifxlabel);
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: ..(lifxlabel) .. "/power.json?state=off";
os.execute(runcommand);
return commandArray
elseif(devicechanged[DomDevice]=='On') then
print ("Turning on " .. DomDevice .. " named " .. lifxlabel);
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: ..(lifxlabel) .. "/power.json?state=on";
os.execute(runcommand);
return commandArray
else
DomValue = (otherdevices_svalues[DomDevice]);
end
CalcValue = DomValue / 31.25;
print ("Dimming " .. (DomDevice) .. " to " .. (CalcValue) .. " ");
runcommand = "curl -H \"Authorization: Bearer " .. (apikey) .. "\" -XPUT https://api.lifx.com:443/v1beta1/lights/label: .. (lifxlabel) .. "/color.json?color=brightness:" .. (CalcValue) .. " ";
os.execute(runcommand);
end
return commandArray
My LiFX Bulb is named "Woonkamer", and the Switch in Domoticz is named Domoticzlifx
Last edited by l00pz on Saturday 04 April 2015 10:52, edited 1 time in total.

mattc
Posts: 8
Joined: Wednesday 25 February 2015 12:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc » Friday 03 April 2015 12:40

Here's an upload of my working script... hopefully will avoid the cut/paste weirdness going on!

Oh, and take your key out of the post above.... your letting anyone control your lights by publishing it!
Attachments
script_device_Lifx.lua.zip
(984 Bytes) Downloaded 109 times

l00pz
Posts: 40
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz » Wednesday 08 April 2015 20:31

Sorry for the late reaction, but with you`re script it seems te be working :) One sidenote though, I keep getting the 32256 error in the Log viewer. Any idea what that could be?
And another question, what type of Switch do I need to add to get the dimming function working?

Post Reply

Who is online

Users browsing this forum: sincze and 2 guests