Gem Version Build Status

This gem allows you to control your LIFX lights.

It handles discovery, gateway connections, tags, and provides a object-based API for talking to Lights.

Due to the nature of the current protocol, some methods are asynchronous.

This gem is in an early beta state. Expect breaking API changes.


  • Ruby 2.0+
  • Tested on OS X Mavericks, but should work other *nix platforms. Please file an issue if you have any problems.


Add this line to your application's Gemfile:

gem 'lifx'

And then execute:

$ bundle

Or install the gem with:

gem install lifx        # Add sudo if required.


client = LIFX::Client.lan                  # Talk to bulbs on the LAN! do |c|                    # Discover lights. Blocks until a light with the label 'Office' is found
                                           # Blocks for a default of 10 seconds or until a light is found
client.lights.turn_on                      # Tell all lights to turn on
light = client.lights.with_label('Office') # Get light with label 'Office'

# Set the Office light to pale green over 5 seconds
green = 0.5)
light.set_color(green, duration: 5)        # Light#set_color is asynchronous

sleep 5                                    # Wait for light to finish changing
light.set_label('My Office')

light.add_tag('Offices')                   # Add tag to light


client.flush                               # Wait until all the packets have been sent


Documentation is available at Please note that undocumented classes/methods and classes/methods marked private are not intended for public use.

LIFX uses the HSBK colour representation. HSB stands for hue, saturation, brightness, and K refers to kelvin.


Examples are located in the examples/ folder.

  • travis-build-light: Changes the colour of a light based on the build status of a project on Travis.
  • auto-off: Turns a light off after X seconds of it being detected turned on.
  • identify: Use divide-and-conquer search algorithm to identify a light visually.

Useful utilities


Run with bundle exec rspec.

The integration specs rely on a least one device tagged with Test to function. At this point, they can fail occasionally due to the async nature of the protocol, and there's not much coverage at the moment as the architecture is still in flux.

A more comprehensive test suite is in the works.


Please file an issue for general feedback, bugs, clarification, examples, etc etc. Feel free to hit me up on Twitter, too: @chendo.