LIFX Developer Zone

LAN API still available


#1

Hello,
I am expecting my first Lifx bulb in a few days. I got the mini dusk white.

I would like to use the LAN API to write a program to flash the bulb. I don’t want cloud or HTTP nonsense.

I want to do something really simple – just flash the bulb on and off for 15 seconds or so.
I will know the IP. Hopefully I can just write to the bulb. Maybe there is a flash command native to the bulb?

I’ve spent quite a few hours looking at the software available, mainly on githup. It seems way more complex than I need. Maybe I can just pull it apart and take the lowest level. I have been a software engineer for 30 + years.

A simple script to just exercise the bulb with documentation showing the individual packet fields, what they consist of, and building the packet, would be really nice.

If someone knows of something really simple, please point it out.

Thanks,
Barry.


#2

What language are you using ? Try LifxLAN or Photons, simply command is all you need to flash them.


#3

Thanks.
I’ll search for those.

I intend to end up with C# (Microsoft Visual Studio Community), but being able to do something simple (like turn on/off using only bulb’s IP) with with a compiled something or script is a huge first step.

Looking at simple, straight forward source is icing on the cake.

My ultimate goal is to use Windows 10 UWP to recognize Skype notifications of an incoming audio, video, or message and then flash a bulb. I am deaf so ring tones don’t help much and I miss the call unless I happen to be staring at the computer screen. Flashing a bulb (an alerter) announces a call.

This is a long way off. Flashing a bulb is the first step. Would you happen to know if something like this already exists?

Barry.


#4

Sorry no, not aware but I am sure I remember others on here doing something similar.
Check this anyway Photons - Opensourcing a new framework for interacting with LIFX lights


#5

Hi,

You’ll want a SetWaveformOptional message https://lan.developer.lifx.com/docs/light-messages#section-setwaveformoptional-119

So with photons (install python3.6+ and pip3 install lifx-photons-core) you could say something like

# Make the light on and full brightness
# transform takes in options similiar to the http api
lifx lan:transform d073d5000000 -- '{"power": "on", "brightness": 1}'
# Make the bulb go to 0 brightness and back a few times
lifx lan:set_attr d073d5000000 waveform_optional -- '{"brightness": 0, "cycles": 15, "period": 1, "waveform" :"SINE", "skew_ratio": 0.5}'

Though if you’re on windows I believe it’s a bit more annoying and you have to escape all the double quotes

or you can write a script that looks like https://gist.github.com/delfick/0147de1cdc9a625bbb9d5b967e2b9840

I’m sure it’s also quite easy with lifxlan.

Unfortunately I’m not really familiar with existing c# LIFX libraries, so I can’t offer any advice there.


LAN API responses
#6

Though lifxlan is a Python module, it certainly does what you’re looking for, and it might be helpful if you want to reverse engineer the LAN packets so that you can build your own in C#. The following code flashes the light a nice, eye-catching cyan and also prints out the packet information used to do so:

from lifxlan import Light, CYAN

light = Light("AB:CD:EF:GH:IJ:KL", "192.168.X.X", verbose=True)
light.set_waveform(True, CYAN, 1000, 2, 0, 4)

In my case, running this code prints out to the terminal each packet’s message type and associated field values, as well as the raw bytes of the entire packet:

SEND: LightSetWaveform
  Size: 57
  Origin: 0
  Tagged: 0
  Protocol: 1024
  Source ID: 64384
  Target MAC Address: d0:73:d5:12:c6:4e
  Ack Requested: 1
  Response Requested: 0
  Seq Num: 0
  Message Type: 103
  Payload:
    Is Transient: True
    Color: [29814, 65535, 65535, 3500]
    Period: 1000
    Cycles: 2
    Duty Cycle: 0
    Waveform: 4
  Bytes:
    ['0x39', '0x0', '0x0', '0x14', '0x80', '0xfb', '0x0', '0x0', '0xd0', '0x73', '0xd5', '0x12', '0xc6', '0x4e', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x2', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x67', '0x0', '0x0', '0x0', '0x0', '0x1', '0x76', '0x74', '0xff', '0xff', '0xff', '0xff', '0xac', '0xd', '0xe8', '0x3', '0x0', '0x0', '0x0', '0x0', '0x0', '0x40', '0x0', '0x0', '0x4']

RECV: Acknowledgement
  Size: 36
  Origin: 0
  Tagged: 0
  Protocol: 1024
  Source ID: 64384
  Target MAC Address: d0:73:d5:12:c6:4e
  Ack Requested: 0
  Response Requested: 0
  Seq Num: 0
  Message Type: 45
  Payload:
    <empty>
  Bytes:
    ['0x24', '0x0', '0x0', '0x14', '0x80', '0xfb', '0x0', '0x0', '0xd0', '0x73', '0xd5', '0x12', '0xc6', '0x4e', '0x0', '0x0', '0x4c', '0x49', '0x46', '0x58', '0x56', '0x32', '0x0', '0x0', '0x68', '0x34', '0x89', '0xe7', '0x52', '0x9', '0x7c', '0x15', '0x2d', '0x0', '0x0', '0x0']

Hopefully that’s helpful in your mission! Also, if you don’t want to bother logging on to your router, you can get the IP and MAC address of the bulb (and other juicy info) by running hello_world.py in the examples folder.