LIFX Support

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

LIFX Support

Post by superczar »

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: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar »

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: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: LIFX Support

Post by pvm »

Lease state in the wiki
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Pi314
Posts: 4
Joined: Friday 23 January 2015 2:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 »

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: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar »

Created a basic wiki page with steps

http://www.domoticz.com/wiki/LIFX
Pi314
Posts: 4
Joined: Friday 23 January 2015 2:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 »

Great, It's work fine.
One thing is missing it's the possibility to access the bulbs individually
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: LIFX Support

Post by Derik »

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: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: LIFX Support

Post by superczar »

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
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: LIFX Support

Post by Derik »

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 2:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 »

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 11:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

LIFX Support

Post by mattc »

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 11:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc »

Added the above to the wiki :)
Pi314
Posts: 4
Joined: Friday 23 January 2015 2:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by Pi314 »

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 11:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc »

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: 10
Joined: Sunday 29 March 2015 20:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2436
Location: Switzerland
Contact:

Re: LIFX Support

Post by phitar »

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: 42
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz »

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: 10
Joined: Sunday 29 March 2015 20:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2436
Location: Switzerland
Contact:

Re: LIFX Support

Post by phitar »

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: 42
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz »

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 11:06
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by mattc »

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 198 times
l00pz
Posts: 42
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz »

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: No registered users and 1 guest