LIFX Support

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

Moderator: leecollings

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

Re: LIFX Support

Post by mattc »

mattc wrote: I've created a dummy switch based on lightwaverf
l00pz
Posts: 42
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: LIFX Support

Post by l00pz »

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 »

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 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 »

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 14:11, edited 1 time in total.
phred91
Posts: 8
Joined: Tuesday 04 February 2014 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 »

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 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by phred91 »

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 3:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by lvidal07 »

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

pi@raspberrypi ~/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

pi@raspberrypi ~/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 3:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by lvidal07 »

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

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

Re: LIFX Support

Post by superczar »

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: 4
Joined: Sunday 01 November 2015 23:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: LIFX Support

Post by fluxcapacitor »

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: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: LIFX Support

Post by kylegordon »

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: 14
Joined: Monday 30 January 2017 12:02
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: LIFX Support

Post by avgays »

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

Re: LIFX Support

Post by superczar »

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: 14
Joined: Monday 30 January 2017 12:02
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: LIFX Support

Post by avgays »

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

Re: LIFX Support

Post by superczar »

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 / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by Mecallie »

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 / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by lometje »

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: 35
Joined: Monday 23 May 2016 8:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: UK
Contact:

Re: LIFX Support

Post by darlomrh »

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.
Saville803
Posts: 1
Joined: Wednesday 20 December 2017 13:00
Target OS: OS X
Domoticz version:
Contact:

musicallyloginmusicallylogin

Post by Saville803 »

I expect that trend to continue. Paradoxically, it could end up as a great place musically There's no chance to select which 15-second clip of the track.
henkp
Posts: 1
Joined: Friday 13 April 2018 17:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LIFX Support

Post by henkp »

I'm really trying very hard to enable my LIFX lights within my fresh Domoticz-installation. I have so far been able to enable the python-plugin as provided above, but it seems there is a bug in the python-implementation as used in this script, which prevents device updates from getting received. I have been able to get the python-script to recognize my lights, but as soon as the lights are entered as devices (and replying to status update polls) the domoticz-installation crashes with a fatal signal 11. This is the exact same behavior as described in http://www.domoticz.com/forum/viewtopic ... 9&start=20 . I see 2 options:

1. downgrade to python 3.4 instead of 3.5 (which handles the calls a bit different and should fix this) or
2. Fix the script so it works in 3.5.

However, both are out of my comfort zone and I wouldn't even know where to start. I really want to get my lights within my domoticz-environment though, so I really hope someone here can help me in achieving one of those options!

Edit: After fiddling about a while, python --version shows me Python 3.4.4, however the python-version mentioned in Domoticz-about-page is still 3.5.3. Do I have to downgrade Domoticz-Python separately as well?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest