Photons

Photons is an asynchronous Python3.12+ framework for interacting with LIFX devices.

Photons provides:

  • High level creation of LIFX packets

  • Transparent device discovery

  • A convenient API for sending packets to multiple devices in parallel and streams responses back.

  • A gatherer for sending the least number of messages to get information from devices.

  • A product registry for determining the capabilities of the devices on your network.

  • Efficient tile animations that can run on low powered devices like a Raspberry Pi

  • A rich set of functionality that can be accessed from the command line

  • A daemon you can run for continuous discovery and information gathering on your network.

  • Useful functionality for common tasks while creating scripts.

  • Flexible configuration capabilities.

Installation

Photons is best installed in a Python virtual environment. The following commands create a virtual environment named .photons-core in the current user’s home directory and installs the latest version of Photons:

$ python3 -m venv ~/.photons-core
$ source ~/.photons-core/bin/activate
$ pip install lifx-photons-core

Note

the virtual environment can be located anywhere on the file system by changing the ~/.photons-core path to the desired location.

After installation, the Photons command-line tool lifx is available in the virtual environment:

$ lifx lan:transform -- '{"power": "on", "color": "red", "brightness": 0.5}'

Source code

The code for photons is found at https://github.com/delfick/photons and includes an examples folder of scripts.