Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Lifx VD guidance


Vuxen

Question

Hi gents, quite a bummer that my old account has gone missing but what to do. 

 

Back to the point. I intend to create a LiFX virtual device as I have a few LiFX bulbs around my home and I can't really integrate them with Fibaro. I've also checked LiFX community and they said:

 

I tried to connect my Lifx bulbs with the HC2. Now it works! I found a lot of information on the subject of http requests in the pages of this forum. 

 

Here you find how I did it:

 

You need to use the new firmware version on Lifx bulbs (version 2.0) - we can do the update in the app on Android.

Register on  

Please login or register to see this link.

 , search the "settings" and register a new "token" for the API. You can find all the API information that exists on 

Please login or register to see this link.

 

Create a new scene in HC2 and put for example:

Please login or register to see this code.

Adapt your LUA code.

For authorization: Take your lifx cloud token, add a ":" and encrypt it in base64 ( 

Please login or register to see this link.

 )

 

That's all, good luck

 

At this point, I'm a bit lost. Any ideas on what he wants to say with adapt your LUA code?

Please login or register to see this code.

this bit was missing

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  •     So technically to get access to LIFX I need to use that first bit in order to control the bulb, but afterwards, how do I create a virtual device that would adjust every colour.   @Sankotronic I don't want to disturb you mate but any hints in creating this would be awesome. Regards   

    Link to comment
    Share on other sites

    • 0

    Hi @Vuxen ,

     

    I have a working VD to control LIFX bulbs using UDP on local network, no cloud involved. I always prefer to have local communication between HC and devices that are on same home network. At the moment I have only UHAS compatible LIFX VD. I'm still testing it at the moment and improving code, cleaning some bugs. Since I'm very busy with developing UHAS I can't say when I will publish standalone version of LIFX VD.

     

    Recently I purchased Ubiquiti ApliFi mesh router and I have some problems with Sonos and LIFX. My ISP modem/router is setup to bridge mode which means it is actually only modem now. I connected AmpliFi router WLAN port to ISP modem LAN port and setup AmpliFi to do internet connection over PPPoE and to manage my local network. It is amazingly easy to do this setup and it is now working flawlessly. Of course I had to communicate several times with my ISP until they finally managed to setup correct profile on their side.

     

    Problems that I have with LIFX is that my HC2 does not get always proper answer from LIFX bulbs when status query is sent. Also sometimes when command is sent to LIFX bulb to, for example, turn on then nothing happens. Since I didn't reset bulbs after replacing my old router that was set to bridge mode with AmpliFi that is something I still have to do to see if there will be improvements. Old router and new Amplifi router WiFi settings are completely same so all my 50 devices are connecting properly to WiFi, but still have to try. That is one reason more why I didn't publish standalone LIFX VD yet.

     

    Sonos is another story, but since it is OT will post about that in another thread.

     

    Link to comment
    Share on other sites

    • 0

    Hello @Sankotronic

     

    Did you ever get the VD complete for the LIFX devices??? i am chasing some examples of this so that i can look at doing a full integration to the HC3 platform. 

    im also looking at trying to integrate to the LIFX LED strip that has multiple zones in the string that can be different colours.

     

    some help here from you would be great if you have a base starting point i could work from.

     

    let me know of any updates.

    Link to comment
    Share on other sites

    • 0

    Hello @CraigR ,

     

    I have a working VD for HC2. It is a part of UHAS that I'm now finishing. After UHAS for HC2 I will do same for HC3.

     

    On local network LIFX is communicating over UDP and it uses binary protocol coded in "little endian". More about endianess you can find here:

    Please login or register to see this link.

     

    Since it uses binary encoding I use these functions to convert response from bulb and messages to the bulb:

    Please login or register to see this code.

    LUA can work with binary strings, but by converting to hexadecimal it can be printed and you will always get same string length so data contained within this string is then easily read with string.sub lua function. Above functions can be used on both HC2 and HC3 without conversion.

     

    Same is with commands sent to LIFX bulb. It is simple to first compose command as hexadecimal string as example below:

    Please login or register to see this code.

    Above string is used to get LIFX bulb state. Since bulb requires identification of the requestor I use hc_serial_no_hex with HC2 serial number converted to hexadecimal number.

     

    LIFX bulb response is of course in binary format, so I convert it to hexadecimal and then I check bulb status by reading parts of the response and convert to decimal as needed:

    Please login or register to see this code.

    Above code is for color bulbs, but same is for white ambience where you get only brightness and color_temp with same code and of course dimmable bulb where only brightness is available. This means that with the same code you can make QA for all types of bulbs and QA will use only data needed :-)

     

    Now to compose command to change state (on/off), brightness and color I first define some parts of the command since are always same and for me to be easier to follow code:

    Please login or register to see this code.

     

    I also write local functions to call when sending command using above definitions:

    Please login or register to see this code.

    NOTE - for HC3 you will need to change above code to use HC3 UDP functions.

    In above code duration is the time it will take to transition to the new state or HSBK color in milliseconds. I read value of slider and then calculate:

    Please login or register to see this code.

    There must be a bug withing their firmware because time duration for turning on bulb and do other transitions is different. You can play with this calculations.

    At last but not least you need to compose payload to send HSBK to bulb:

    Please login or register to see this code.

     

    I think this is about it to make workable QA or VD to communicate with LIFX bulbs. I didn't yet play with bulb grouping and didn't have chance to write code to control multi zone LIFX since I do not have such light so can't test the code. You are mostly welcomed to use and improve above code.

     

    Enjoy coding :-)

     

     

     

     

     

    Edited by Sankotronic
    code correcting
    • Thanks 1
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...