LIFX equipment

Discussion in 'C-Bus Automation Controllers' started by philthedill, Jun 29, 2020.

  1. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    Has anyone found a way to integrate LIFX bulbs/LED strips etc into CBus via a SHAC? I was trying to use an Alexa routine but unable to activate a routine via Smartvoice. For some reason, Alexa has an extremely limited list of "smart devices" that are eligible to initiate a routine.
     
    philthedill, Jun 29, 2020
    #1
  2. philthedill

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    422
    Likes Received:
    50
    Location:
    Perth
    U need Homebridge and Homebridge CBUS or to code specific commands to be despatched over the LAN port.

    But honestly > why?

    CBUS is vastly superior for the switching, use that and ditch the poor quality end point hardware and complexity.
     
    chromus, Jun 29, 2020
    #2
  3. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    thanks Chromus,

    I understand that homebridge will require a pi of something like that running all the time. However, my preferred option would be to issue instructions directly from my SHAC. Can you/anyone provide some sample script that following a lot of trial and error will allow me to get to something that works? ( Adressing your second point .... My C-Bus has 98 devices and I am not changing any of that out.,I ve added a few LIFX devices for very specific applications and am keen to be able to operate them from C-Bus)
     
    philthedill, Jun 30, 2020
    #3
  4. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    It Should be relatively simple according to their api doc https://lifx.readme.io/

    Use http post command from lua script
     
    Pie Boy, Jun 30, 2020
    #4
  5. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    thank you Pie Boy, I am a novice - any chance of a sample script that I can modify? thanks
     
    philthedill, Jul 1, 2020
    #5
  6. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    the following is returning an error when I try to save it - any ideas?

    socket.udp()

    sendto(31 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 00 00 00 00 55 55 FF FF FF FF AC 0D 00 04 00 00, 192.168.86.23, 56700)

    close()

    with thanks
     
    philthedill, Jul 8, 2020
    #6
  7. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    Pie Boy, Jul 8, 2020
    #7
  8. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    thank you Pie Boy - this saved ok so we are over that hurdle but did not activate light as expected. I had copied the instruction from the example given on the LIFX site https://lan.developer.lifx.com/docs/building-a-lifx-packet so it should work okay - any other ideas? we are on the right track.
     
    philthedill, Jul 8, 2020
    #8
  9. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    Can you test/ prove that command with packet sender or similar to see if you have connectivity and command correct,
    Another method would be to run up wireshark and determine if the shac is sending packets etc
    Also dose the lifx have an app? and dose that app use the lan protocol, id say it’s unlikely it dose, but if it dose you would see that traffic on the wireshark also.
    Also I’m not familiar with lifx, dose it have a hub as such? And dose it require anything to be enabled to use the lan protocol?
     
    Pie Boy, Jul 12, 2020
    #9
  10. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    I've used wireshark to confirm that my PC is issuing a message to SHAC to run the relevant event script. However, there is no messaging going from SHAC back onto the network to activate the LIFX light.
    LIFX does not need a hub and can be activated by a LAN UDP message - the plot thickens!
    any further ideas?
    btw my "user function library" contains only the email program and dawn/dusk calculator (both are in use and working fine) - should there be anything else in there?
    cheers
     
    philthedill, Jul 13, 2020
    #10
  11. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    Can you successfully send the lan protocol UDP command from your computer without the shac and thus proving connectivity and udp command is correct?
     
    Pie Boy, Jul 13, 2020
    #11
  12. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    try this for on and off, run in an event script, on and off will follow level 0 and 255 of the object

    cmd_on = string.char(0x2A, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00)

    cmd_off = string.char(0x2A, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)

    local level = event.getvalue()

    function lifx_cmd(cmd)
    require('socket').udp():sendto(cmd, '192.168.86.23', 56700)
    end

    if level == 0 then
    lifx_cmd(cmd_off)
    end

    if level == 255 then
    lifx_cmd(cmd_on)
    end
     
    Pie Boy, Jul 14, 2020
    #12
    philthedill likes this.
  13. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    I was able to use an app to work the light from PC and then used Wireshark to capture the packets. However I had no luck with trying to issue the command from PC using Packer Sender. The good news is that your script works perfectly. Thank you for your help!
     
    philthedill, Jul 14, 2020
    #13
  14. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    Dear Pie Boy, I can turn my lights on and off - which is great but the boss is asking about colours and levels. I've had a good look at what you sent me but I cannot relate it back to LIFX instructions without making some huge assumptions. Would you mind sharing your thinking with me so that i can then modify what you have done and be able to set colours and levels (by establishing separate groups for each setting)?
     
    philthedill, Jul 16, 2020
    #14
  15. philthedill

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    All good, i just basically interpreted the lifx doc to make the on/off commands, you would need to do the same for dimming and colour changing, once you know the command, (it helps if you can qualify the command with packet sender or similar making sure it works before sticking it into the SHAC)
    then just modify the code to suit or put the function it a library and call it from where ever

    the simple way
    -- create user library with the below
    Code:
    function lifx_cmd(cmd)
    require('socket').udp():sendto(cmd, '192.168.86.23', 56700)
    end
    
    Then you can call the function from any script as below with the function call, just change your commands (cmd=...)to suit what you want the lifx to do.

    Code:
    cmd = string.char(0x2A, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00)
    
    function lifx_cmd(cmd)
    
    The more complex way would be to build some code that makes the lifx packets based on some varibles and then has a function call to execute, but this is more complex and if you only have a couple of lifx devices, there is not really any point to do it this way.
     
    Pie Boy, Jul 21, 2020
    #15
  16. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    I'll certainly avoid the "more complex way" at this stage and appreciate your assistance. It is the makeup of the command that I am struggling to relate back to the LIFX doc. Might you be good enough to identify which sections of the on/off sample that you provided (and I've been able to get working across 4 lamps) relate to on/off, colour and brightness. I should be able to take it from there (with luck!)
     
    philthedill, Jul 22, 2020
    #16
  17. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    I've made a bit of progress and can now control the transition time by fiddling with the last four bits. Still no luck with brightness, and colour....
     
    philthedill, Jul 23, 2020
    #17
  18. philthedill

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Did you get this going? I have just been testing a Lifx downlight and wrote a test script to set the color. I can post it if you like.

    Not very impressed with the dimming ability of these devices :(. Don't think I'll be using any.
     
    Ashley, Aug 1, 2020
    #18
    philthedill likes this.
  19. philthedill

    philthedill

    Joined:
    Mar 21, 2010
    Messages:
    140
    Likes Received:
    3
    Location:
    Melbourne
    Hi Ashley,
    I've not made any more progress and confirm that I can now turn lamps on/off and adjust the transition time. No luck with colour or dimming so if you have cracked the colour side of things I might be able to combine your work with what I got from PieBoy earlier. Please post what you have - with thanks
     
    philthedill, Aug 1, 2020
    #19
  20. philthedill

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Ashley, Aug 5, 2020
    #20
    philthedill likes this.
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.