LIFX Light Bulbs

Begonnen von franc, 17 August 2014, 10:39:44

Vorheriges Thema - Nächstes Thema

franc

I've pushed a new version to github that has more updates and works reasonably well on my raspberry pi. Can you grab the new version and try the examples/monitor.py - it should print the message types and mac addresses of the Bulbs it sees.

No need to run it with the PERLDB_OPTS, it looks like the Perl on your system and on mine are compiled with different debug options and hence I can't get much info from those logs

cheers

andrejs

#16
Franc,
I copied Device directory and examples from your Github on my Ubuntu and ran monitor.pl script. The printed result was "Timeout".
I checked attached devices on my Netgear router and life bulb is on the list (see attached file). I am also able to control life bulb with iOS application.
I also created short perl script (printenv6.pl)  to switch off the life bulb. I have not got any error message but unfortunately the bulb stayed switched on.I think it should be something wrong with the protocol. For the protocol I followed the instructions https://github.com/magicmonkey/lifxjs/blob/master/Protocol.md but I am not sure if it is still valid. In my case the message was created as follows:

$size\x00\x00\x14\x00\x00\x00\x00$machex\x00\x00$machex\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$command\x00\x00\x00\x00$payload

$size=pack("H*","26");
$command=pack("H*","15");
$payload=pack("H*","00");

script for $machex (because I have just one life bulb it is also a gateway)
my $zmac='d0:73:d5:01:45:ba';
  $zmac=~ s/://g;
  my $i=0;
  my $machex;
  my ($a,$c);
  my $n = length($zmac);
 
  while($i<$n)
    {
    $a =substr($zmac,$i,2);
    $c = pack("H*",$a);
      if ($i==0){$machex=$c;}
      else {$machex.=$c;}
      $i+=2;
    }

Could you please tell me do you use the same protocol/message to switch off the life bulb?


Andrej

franc


The docs at MagicMonkey are mostly correct for the new firmware, however the second $machex has been replaced with "LIFXV2".

That repo also contains a wireshark protocol interpreter for the LIFX protocol, which I found very useful. If you install Wireshark along with the protocol intepreter than you will be able to see the packets in a readable form

cheers

andrejs

Thank you very much Franc for your answer it was very useful because after I replaced second $machex with LIFXV2 I was able to switch off the bulb. Chancing the $payload I managed to switch on the bulb.
I ran again monitor.pl but the result was the message "Timeout" and not the mac address of the bulb. Do you know what should be wrong here?

Thanks

Andrej

franc


Hi,

That's mysterious, I'm sot sure what is going wrong with my code. Are you comfortable with sending me a packet dump of the communications to your Bulbs ? If so, could you run:-

   sudo tcpdump -n -s0 -i eth0 -w lifx.pcap port  56700

the run your script that works, followed by my script that does not.

Once you have done that can you send the lifx.pcap file and I will have a look at it to see what is going on

cheers





andrejs

Franc,
I followed your instructions and here is the file lifx.pcap.

Andrej

franc

Hi Andrejs,

I'm afraid that packet capture is empty - It may be that your network interface is not called eth0, could yo send the output of

  ifconfig -a

(sorry this is taking so long to debug)

cheers

andrejs

#22
Franc,
the problem was because I forgot to open udp port 56700 (I opened just tcp port 56700) on firewall. I defined LIFXBridge and LIFXBulb in FHEM and it works!!! :D
I added attribute webcmd to lifxbulb rgb:rgb FF0000:rgb FFFFFF:rgb 0000FF:toggle:on:off  and I was able also to change colors! You really have done very nice module. Thank you again.
I notices just one issue. When I tried to change color (see attached part of my print screen at the top of picture) device lifxbulb was shutdown/deleted. I checked the log but nothing was there.

Andrej

franc


Great, I'm glad it works.

I've found (and fixed) the bug with color (thanks for finding it), if you pull the fhem-lifx from github you should see that 'color' has been changed to 'kelvin' and works properly.

d.schoen

I made some improvements to the module, according my needs here: https://github.com/dsgrafiniert/fhem-lifx

Feel free to contribute.
FHEM 5.7 auf RasPi2
COC 868MHz, Jeelink Clone
Devices: IT, HomeMatic, LaCrosse, ENIGMA2, LG-TV, Thinkingcleaner (iRobot Roomba), LIFX Wifi-Bulbs
Helper: TelegramBot, Homebridge (Siri), Geofency

fringl

Hi,

I'm new to this forum and also fhem, which I am currently trying to get connected to my lifx bulbs. I still have an issue hopefully someone can help me with:

The perl test scripts went fine (switching light on/off), and I could define the bridge in fhem no problem. However, I cannot define the bulb correctly by using the command "define LIFX_Bulb1 LIFXBulb d0:73:d5:01:29:e9"

The problem is the ID parameter of the bulb, which looks somehow cryptic and not seem to be valid:

DEF             d0:73:d5:01:29:e9
ID               �s�)�
IODev         LIFX_Bridge
NAME          LIFX_Bulb1
NR              28
STATE        Initialized
TYPE           LIFXBulb

I have used the original (franc's) sw version.

thanks for the help.... 
Ingo

franc


Hi Ingo,

The ID is not necessarily a problem - the approach I used was a bit buggy/silly/naive as I wrote the module when I was new to fhem.

I assume other than it 'looking wrong' that when you try to control the light through fhem's UI it does not work - correct ?

Can you have a look in the fhem.log for LIFX related message for anything that looks odd. If nothing pops out at you grep the logs for LIFX stuff and I'll see if I can see an issue

cheers

Aikawa24

Hi, i am switching the Lifx with Homebridge over fhem because fhem was my first project.

the Lifx switch flawless in fhem but in Homebridge i got some error and i can switch only once

LIFXSchlafzimmer-rgb not a number: aN
[Fri Nov 25 2016 01:42:10 GMT+0100 (CET)] [FHEM]   value converted to aN

does anyone knows what it is ?

Thanks