LIFX Light Bulbs

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

Vorheriges Thema - Nächstes Thema

franc


Hi,

I have written a module for LIFX Light Bulbs, you can find it here:-

https://github.com/franc-carter/fhem-lifx.git

It doesn't expose all of the functionality of the Bulbs, but I have found the subset complete enough to be useful

cheers

andrejs

Nice work! I really want to test it because I have one LIFX bulb installed. My question is for testing I need to copy all 3 pm modules (LIFX.pm, LIFXBulb.pm, LIFXBrigde.pm) in FHEM directory and add  "define" sentence in cfg file?

Cheers

Andrej

franc


Hi,

I'm afraid there isn't a nice clean install at the moment, so there is several steps - I'll go through them below.

1. Get the Perl LIFX module from https://github.com/franc-carter/perl-lifx.git
2. Copy the 'Device' directory in your Perl Library path somewhere (probably O/S, version etc dependent)
3. Run ./examples/example1.pl  <LABEL>  where <LABEL> is the name you have assigned the Bulb
4. This should turn the Bulb on and off and shows that the Perl module is working

Once this works the FHEM module can be installed


1. Get the FHEm module from https://github.com/franc-carter/fhem-lifx.git
2. Copy 30_LIFXBridge.pm  and 31_LIFXBulb.pm to the FHEM modules directory
3. Add the following to your FHEM config

     define <BRIDGE_NAME> LIFXBridge
     define <BULB_NAME>    LIFXBulb <BULB_IDENTIFIER>

     where <BRIDGE_NAME> and <BULB_NAME> are whatever you like
     and <BULB_IDENTIFIER> is either the Bulb MAC address or Bulb Label

You should then be able to use the Bulb in the rest of the FHEM rules.

Let me know how you go







andrejs

#3
Hi Franc
Thanks for the instructions. Unfortunately I stucked at running example1.pl. I copied the Perl LIFX Module at /usr/bin/perl (I am using Ubuntu 14.04) and after that run in terminal ./examples/example1.pl d0:73:d5:01:45:ba. No error messages have been displayed but the script hang in the loop and I was forced to end it with ctrl C. I checked the mac address of the bulb and it is correct. I looked at the pl script and I think the problem is  this part:

my $bulb = undef;
while(!defined($bulb)) {
    my $msg = $lifx->next_message(1);
    if (defined($mac)) {
        $bulb = $lifx->get_bulb_by_mac($mac);
    } else {
        $bulb = $lifx->get_bulb_by_label($ARGV[0]);
    }
}

Maybe just one additional information I upgraded a few days ago the firmware of lifx bulb.

Andrej

franc


Hi,

Can you replace that section of code with the code below and tell me what it prints. I have also upgraded to the new firmware so that should be fine.

my $bulb = undef;
while(!defined($bulb)) {
    my $msg = $lifx->next_message(1);
print "$msg\n";
    if (defined($mac)) {
        $bulb = $lifx->get_bulb_by_mac($mac);
print "$bulb\n";
    } else {
        $bulb = $lifx->get_bulb_by_label($ARGV[0]);
    }
}

cheers

andrejs

Hi Franc,

I replaced the section of the code and run again. No error messages have been displayed just the empty lines are displayed. I was forced again to stop the script with ctrl C.

Andrej

franc


Ok, let's try looking at a more detailed log of what is happening. Can you run

script -a lifx.log -c 'PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS ./examples/example1.pl d0:73:d5:01:45:ba'

and then end me the lifx.log, hopefully I'll be able to work out what is happening from that

cheers

franc

I just had a thought - are you running a 32bit version of Ubuntu ? what's the output of uname -a

cheers

andrejs

Thanks Franc for a quick reply. Please find life.log attached to this message. My Ubuntu/Linux version is:

Linux andrejs-MCP79 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux

Cheers

Andrej

franc


Ahh, i686 - that's 32 bit I'm afraid. I discovered yesterday that the modules does not work at all on 32bit machines ;-(

I've started to fix it, but it is more difficult than I first hoped.

I'm guessing it will take about a week, unless it's even messier than I expect - I'll let you know once I have it fixed

sorry

andrejs

It OK Franc I am prepared to wait because I am really interested to have lifx installed in FHEM.

Thanks again

Andrej

franc


Hi Andrej,

I've made some progress, the version of the module I have attached partially works on my raspberry pi. Could you try the example programs using this new version and let me know if it works better.

thanks

andrejs

Hi Franc,

I tried to run example1.pl and got the following error:

ZitatHexadecimal number > 0xffffffff non-portable at /usr/lib/perl5/Device/LIFX.pm line 343.


Andrej

franc


You can ignore that message for the moment, it's to do with managing the Tags on the Bulbs - I haven't fix that part yet.

Did example1 manage to turn your Bulb on/off

cheers

andrejs

Hi Franc,

unfortunately I was not able to switch off/on the bulb. I ran the script again script -a lifx.log -c 'PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS ./examples/example1.pl d0:73:d5:01:45:ba' and I attached the log file to this message.

Andrej