LIFX Support

Compatibility (hardware, devices and OS)
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 16 April 2015 13:43

mattc wrote: I've created a dummy switch based on lightwaverf

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

Re: LIFX Support

Post by l00pz » Sunday 26 April 2015 10:08

Thanks! I don`t know what I did wrong the last time, but I got it working now with the Lightwaverf Switch :)

patrickvanelk
Posts: 1
Joined: Monday 29 June 2015 13:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by patrickvanelk » Monday 29 June 2015 13:45

Error 32256 is because of permissions, do a chmod 755 on the script and it should work.

Minor typo on the wiki page:
"2) Copy the following code and save as domoticz/scripts/luascript_device_Lifx.lua" -> "2) Copy the following code and save as domoticz/scripts/lua/script_device_Lifx.lua"

phred91
Posts: 8
Joined: Tuesday 04 February 2014 10:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 » Thursday 28 January 2016 14:46

Hopefully someone can help. I'm trying to get my LIFX light to simply switch on and off.

I created a simple file called lifx_on.py with the following text:

import lifx
lights=lifx.Lifx()
lights.on()

When I run the above script (sudo python lifx_on.py) the light doesn't switch on and I get the following reply:

Code: Select all

('0.0.0.0', 56700)
Found light at 192.168.1.132:56700
Traceback (most recent call last):
  File "lifx_on.py", line 5, in <module>
    lights=lifx.Lifx()
  File "/home/pi/lifx-python/lifx/lifx.py", line 11, in __init__
    self.network = Network()
  File "/home/pi/lifx-python/lifx/network.py", line 27, in __init__
    self.connect()
  File "/home/pi/lifx-python/lifx/network.py", line 75, in connect
    raise serr
socket.timeout: timed out
All of the sample scripts yield similar results: Found light... Traceback... timed out.

I can control the light from my Android phone with no issues.

Has anyone got any ideas about what is going wrong with the python script?

Thanks!

David
Last edited by phred91 on Thursday 28 January 2016 15:11, edited 1 time in total.

phred91
Posts: 8
Joined: Tuesday 04 February 2014 10:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 » Thursday 28 January 2016 15:08

I'm also having trouble with using the Beta API.

I signed on to the portal at https://cloud.lifx.com/ and generated a token called livingroom01.

I created a Dummy switch called Lifx:
Image

I copied the token into the script and created a file in ~/domoticz/scripts/lua/luascript_device_Lifx.lus as follows:

Code: Select all

commandArray = {}

DomDevice = 'Lifx'
lifxlabel = 'livingroom01'
apikey = 'ca757a2980a58e016bd6c91e79c********************bc94c261b5a91bb054'

 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=brightne$
   os.execute(runcommand);
 end
return commandArray
Clicking the on/off button on the control yields no errors (see below), nor does it do anything to the light.
2016-01-28 12:50:15.157 User: Admin initiated a switch command
2016-01-28 12:50:15.182 LUA: Turning off Lifx
2016-01-28 12:50:15.159 (Lifx) Lighting 5 (Lifx)
I notice that some people have " after the url string in the runcommand lines, some people don't. For me, removing this " caused lots of errors, so I put it back.

Any suggestions?

Thanks,

David

phred91
Posts: 8
Joined: Tuesday 04 February 2014 10:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 » Monday 01 February 2016 11:00

Solved my own problem. In the Android app I also changed the name of the light to 'livingroom01' and presto, the dummy switch is now working!

lvidal07
Posts: 2
Joined: Wednesday 24 February 2016 4:55
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by lvidal07 » Wednesday 24 February 2016 8:21

So I've hit a wall here, cant seem to control my LIFX using either the API or python script methods.Using the python method I get the following error:

Code: Select all

[email protected] ~/lifx-python $ python lifx_on.py
('0.0.0.0', 56700)
Found light at my.ip.address:56700
Traceback (most recent call last):
  File "lifx_on.py", line 6, in <module>
    lifx.Lifx().on()
  File "/home/pi/lifx-python/lifx/lifx.py", line 11, in __init__
    self.network = Network()
  File "/home/pi/lifx-python/lifx/network.py", line 27, in __init__
    self.connect()
  File "/home/pi/lifx-python/lifx/network.py", line 75, in connect
    raise serr
socket.timeout: timed out
Using the API method I get no feedback at all, my log is empty and I don't know what else to do. When I run the script_device_LIFXoffice.lua I get this error:

Code: Select all

[email protected] ~/domoticz/scripts/lua $ lua script_device_LIFXoffice.lua
lua: script_device_LIFXoffice.lua:1: unexpected symbol near '▒'
My lua code is:

Code: Select all

commandArray = {}
 
DomDevice = 'Lifx'
lifxlabel = 'LIFXoffice'
apikey = 'c1emyapi677'
 
 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

lvidal07
Posts: 2
Joined: Wednesday 24 February 2016 4:55
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by lvidal07 » Thursday 25 February 2016 3:42

OK, some progress... I at least realized my .lua file was utf-8 no ASCII encoding. So I converted it to ASCII and have a new error.

Code: Select all

[email protected] ~/domoticz/scripts/lua $ lua script_device_LIFXoffice.lua
lua: script_device_LIFXoffice.lua:7: attempt to index global 'devicechanged' (a                                                                              nil value)
stack traceback:
        script_device_LIFXoffice.lua:7: in main chunk
        [C]: ?
I'm new to all of this, so I don't really know what this means. Clicking on the device in the dashboard also does nothing and does not add to the log. The device is based on a dummy Lifx hardward I made.

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 » Thursday 17 November 2016 10:08

Perhaps it's time to re-request native LIFX support on Domoticz
LIFX seems to be almost as popular as Philips Hue - I have them working directly via Echo as well as smartthings but given that Domoticz continues to be my primary controller, would love to see direct support for them within Domoticz..
Happy to help with testing in any way I can

fluxcapacitor
Posts: 6
Joined: Monday 02 November 2015 0:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by fluxcapacitor » Thursday 24 November 2016 11:49

I'm interested too. Currently my LiFX light bulbs work well directly in homebridge thanks to this plugin: homebridge-lifx-lan
Maybe a developper could implement it into Domoticz?

kylegordon
Posts: 96
Joined: Friday 01 November 2013 0:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: LIFX Support

Post by kylegordon » Sunday 27 November 2016 12:36

If it helps in any way, Lifx is certified by the Alljoyn/Allseen/Iotivity alliance. I put some info up at http://www.domoticz.com/forum/viewtopic ... 2&p=106088
1 x HP DL380 & KVM
1 x RPI
1 x RFXtrx433 V78
11 x LWRF Switches
1 x LIFX
2 x Echo Dots
6 x Byron PIRs
2 x Nexa PIRs
2 x Kodi
2 x ESP8266 MQTT
1 x GPIO/MQTT PIR
1 x GPIO(PWM)/MQTT LEDs
1 x GPIO(SPI)/MQTT LPD6803 LEDs
Lots of Node-Red glue

avgays
Posts: 11
Joined: Monday 30 January 2017 13:02
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: LIFX Support

Post by avgays » Sunday 12 February 2017 18:56

My first attempt to write Lifx control, using new Python plugin:

Requires:
• Latest Domoticz with Python plugins enabled (now beta V3.6675 and higher)
• lightsd daemon by lopter https://github.com/lopter/lightsd

Tested on raspberry pi. Plugin itself should work on windows, but daemon only on nixs systems
Tested with Original 1000, White 800, White 900, Color 1000 and LIFX Z.
Only "on", "off", and dimmer. No Color Picker.
Auto-retry "on" and "off"
Updates status of lamps every 2 minutes

First check if Python plugin system is working. Now it's in beta stage, so may be some problems.
http://www.domoticz.com/forum/viewtopic ... 65&t=15233
Try to install and run any example plugin.

Install lightsd daemon:
The lightsd daemon documentation:
http://lightsd.readthedocs.io/en/latest/index.html

Build instructions:
http://lightsd.readthedocs.io/en/latest ... u-raspbian

After installation, enable lightsd at boot:

Code: Select all

sudo systemctl enable lightsd
Enable network interface (not necessary, only if you installs daemon on another machine):

Code: Select all

sudo nano /usr/lib/systemd/system/lightsd.service
add in the end of "ExecStart=" "-l 0.0.0.0:32069" to listen on all interfaces configured with an IPv4 address on your system and on port 32069

Code: Select all

sudo systemctl daemon-reload
sudo systemctl restart lightsd
Check lightsd status:

Code: Select all

sudo systemctl status lightsd
● lightsd.service - LIFX WiFi smart bulbs control service
   Loaded: loaded (/usr/lib/systemd/system/lightsd.service; enabled)
   Active: active (running) since Sun 2015-12-06 01:45:48 UTC; 1h 59min ago
 Main PID: 19060 (lightsd)
   CGroup: /system.slice/lightsd.service
           └─19060 lightsd: listening_on([::]:32069, /run/lightsd/socket); command_pipes(/run/lightsd/pipe); lifx_gateways(found=2); bulbs(found=4,...
> "listening_on([::]:32069, /run/lightsd/socket);" - Port and Unix Socket
> bulbs(found=4... - number of bulbs? daemon found in your network


install LIFX python plugin https://github.com/avgays/Domoticz/blob ... /plugin.py
in "/domoticz/plugins/Lifx/"

After restart of Domoticz "Lifx Plugin" should appear in Hardware tab.
Parameters:
Rescan: True - for the first time to add devices.
All the lamps should be online at moment of adding hardware.
Number of created devices should be equal to "bulbs(found" in "systemctl status lightsd" output.
Later Rescan may be changed to False.

if you enabled network interface:
- "IP Address" and "Port" - address and port of computer, running daemon
- Socket Type: "Inet"
else:
- Unix Socket: from the output of "systemctl status lightsd" - e.g. "/run/lightsd/socket"
- Socket Type: "Unix"
For me - unix socket works bit faster.

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 » Sunday 19 March 2017 0:00

avgays wrote:My first attempt to write Lifx control, using new Python plugin:

/systemd/system/lightsd.service[/code]
add in the end of "ExecStart=" "-l 0.0.0.0:32069" to listen on all interfaces configured with an IPv4 address on your system and on port 32069

Code: Select all

sudo systemctl daemon-reload.......
For me - unix socket works bit faster.[/quote]
Just done installing the plugin!
Great work and many thanks.
Would of course be a bit much to ask if you could add color wheel support as well but will certainly look forward to that if you do decide to :)

avgays
Posts: 11
Joined: Monday 30 January 2017 13:02
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: LIFX Support

Post by avgays » Monday 20 March 2017 13:51

superczar wrote: Would of course be a bit much to ask if you could add color wheel support as well but will certainly look forward to that if you do decide to :)
Currently Domoticz's RGB and RGBW switches sends to plugin only Color(Hue) and Brightness, but no Saturation. So it's very limited support to set Lifx color :(

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 » Wednesday 22 March 2017 7:56

avgays wrote:
superczar wrote: Would of course be a bit much to ask if you could add color wheel support as well but will certainly look forward to that if you do decide to :)
Currently Domoticz's RGB and RGBW switches sends to plugin only Color(Hue) and Brightness, but no Saturation. So it's very limited support to set Lifx color :(
How about using a predefined saturation setting?
Perhaps a variable that could be set on the plugin hardware page to say 50 by the user and all subsequent commands from the plugin use that as the saturation value
While it would have been great to adjust saturation on the fly but this workaround would at least enable partial usage of the color functionality

Mecallie
Posts: 3
Joined: Monday 19 June 2017 23:56
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by Mecallie » Tuesday 20 June 2017 0:02

Is there any way to get real integration of LIFX bulbs going? I have tried the python scripts that have been around since 2015, but that only detects one bulb at random. Not of much use... Currently I am using Yeelights RGBW lightbulbs, because they simply work from Domoticz. And I would rather not completely haul over my RPI2 Domoticz setup just to accomodate the LIFX bulbs, custom stuff always breaks when the official stuff get's an update...

However the LIFX have noticably more light and much nicer white/yellow tones. So I would love to get them working.

I am not a programmer, but I would be willing to gift someone a RGBW LIFX bulb if they get a nice integration going? :) And of course help out testing if needed.

lometje
Posts: 1
Joined: Sunday 13 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LIFX Support

Post by lometje » Sunday 13 August 2017 18:04

I have tried the python scripts that have been around since 2015, but that only detects one bulb at random. Not of much use..
Just now I had the same issue, but using the Lifx API with the Lua script does work. However I would also like to see better support. Right now the switch does not get the active status. For example when I use the Lifx app or lightswitch to turn the light on, domoticz still shows it turned off...

User avatar
darlomrh
Posts: 41
Joined: Monday 23 May 2016 8:03
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: UK
Contact:

Re: LIFX Support

Post by darlomrh » Saturday 19 August 2017 23:18

If you are using Node Red already, node-red-contrib-node-lifx may help you.

I have that and listen for any events from a virtual switch. I also push to Domoticz from node-red for any changes in status on LIFX bulb. One gotcha though: make sure you filter out the update that is passed back from Domoticz if you do update via the LIFX app, otherwise you get into an infinite loop.

Happy to post my flow to anyone who may find it useful.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests