/lazylights

A Python API for controlling Lifx bulbs.

Primary LanguagePythonMIT LicenseMIT

Lazylights

Lazylights is a Python API for controlling Lifx bulbs.

Support for 2.0 is on a branch

What's running on the master branch is deprecated -- see the 2.0 branch with a much simpler API for working with bulbs with the 2.0 firmware.

Until that's merged and on PyPI:

pip install git+https://github.com/mpapi/lazylights@2.0

Quick start

To install,

pip install git+https://github.com/mpapi/lazylights

Then, in Python,

from lazylights import Lifx
import time

lifx = Lifx(num_bulbs=2)  # so it knows how many to wait for when connecting

@lifx.on_connected
def _connected():
    print "Connected!"

with lifx.run():
    lifx.set_power_state(True)
    time.sleep(1)
    lifx.set_power_state(False)

Features

  • connection management
  • high- and low-level interfaces for sending and receiving data
  • callback-based, non-blocking, and blocking APIs
  • no dependencies other than Python

Documentation

Not much here yet, sadly, but the code is fairly well-documented. See the docstrings, or check out the examples directory.

Hacking

pip install -r dev_requirements.txt
flake8 *.py && nosetests

Credits

The lifxjs Protocol wiki page was particularly helpful in the creation of this package.

License

Licensed under the MIT license. See the LICENSE file for the full text.