Skip to main content

Control USB connected LED lights, like a human.

Project description

BusyLight Project Logo

version dependencies pytest license monthly-downloads Code style: black

BusyLight for Humans™ gives you control of USB attached LED lights from a variety of vendors. Lights can be controlled via the command-line, using a HTTP API or imported directly into your own python project.

All Supported Lights

Six Lights Attached to One Host
Back to Front, Left to Right
BlyncLight, BlyncLight Plus, Busylight
Blink(1), Flag, BlinkStick

Features

If you have a USB light that's not on this list open an issue with the make and model device you want supported, where I can get one, and any public hardware documentation you are aware of.

Basic Install

Installs only the command-line busylight tool and associated modules.

$ python3 -m pip install busylight-for-humans 

Web API Install

Installs uvicorn and FastAPI in addition to busylight:

$ python3 -m pip install busylight-for-humans[webapi]

Linux Post-Install Activities

Linux controls access to USB devices via the udev subsystem. By default it denies non-root users access to devices it doesn't recognize. I've got you covered!

You'll need root access to configure the udev rules:

$ busylight udev-rules -o 99-busylights.rules
$ sudo cp 99-busylights.rules /etc/udev/rules.d
$ sudo udevadm control -R
$ # unplug/plug your light
$ busylight on

Command-Line Examples

$ busylight on               # light turns on green
$ busylight on red           # now it's shining a friendly red
$ busylight on 0xff0000      # still red
$ busylight on #00ff00       # now it's blue!
$ busylight blink            # it's slowly blinking on and off with a red color
$ busylight blink green fast # blinking faster green and off
$ busylight --all on         # turn all lights on green
$ busylight --all off        # turn all lights off

HTTP API Examples

First start the busylight API server:

$ busylight serve
INFO:     Started server process [20189]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8888 (Press CTRL+C to quit)

The API is fully documented and available @ https://localhost:8888/redoc

Now you can use the web API endpoints which return JSON payloads:

  $ curl -s http://localhost:8888/1/lights
  ...
  $ curl -s http://localhost:8888/1/lights/on | jq
  {
    "light_id": 0,
    "action": "on",
    "color": "green"
  }
  $ curl -s http://localhost:8888/1/lights/off | jq
  {
    "light_id": 0,
    "action": "off"
  }
  $ curl -s http://localhost:8888/1/light/0/on/purple | jq
  {
    "light_id": 0,
    "action": "on",
    "color": "purple"
  }
  $ curl -s http://localhost:8888/1/light/0/off | jq
  {
    "light_id": 0,
    "action": "off"
  }
  $ curl -s http://localhost:8888/1/lights/on | jq
  {
    "light_id": "all",
    "action": "on",
    "color": "green"
  }
  $ curl -s http://localhost:8888/1/lights/off | jq
  {
    "light_id": "all",
    "action": "off"
  }
  $ curl -s http://localhost:8888/1/lights/rainbow | jq
  {
    "light_id": "all",
    "action": "effect",
    "name": "rainbow"
  }

Code Examples

Adding light support to your own python applications is easy!

Simple Case: Turn On a Single Light

In this example, we pick an Embrava Blynclight to activate with the color white.

from busylight.lights.embrava import Blynclight

light = Blynclight.first_light()

light.on((255, 255, 255))

Slightly More Complicated

The busylight package includes a manager class that great for working with multiple lights or lights that require a little more direct intervention like the Kuando Busylight series.

from busylight.manager import LightManager, ALL_LIGHTS
from busylight.effects import rainbow

manager = LightManager()
for light in manager.lights:
   print(light.name)

manager.apply_effect_to_light(ALL_LIGHTS, rainbow)
...
manager.lights_off(ALL_LIGHTS)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

busylight-for-humans-0.10.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

busylight_for_humans-0.10.0-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file busylight-for-humans-0.10.0.tar.gz.

File metadata

  • Download URL: busylight-for-humans-0.10.0.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.4 Darwin/20.4.0

File hashes

Hashes for busylight-for-humans-0.10.0.tar.gz
Algorithm Hash digest
SHA256 e14f31c787ff1fa6c4c0816a5a43e91ea2e2d0e966c7f435c89f72ed69de03df
MD5 ba67d7183e3d5614f30fa5f23c1b2831
BLAKE2b-256 c48984a2a2fe2fa801e07aee2dc96840cf8a144948856b0cc83e7480295a06d9

See more details on using hashes here.

File details

Details for the file busylight_for_humans-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for busylight_for_humans-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d0ed58c237acf11e2a61aea37e60e3a0b3887b43ed2dc358a4620bbc0779150
MD5 bc37ded57080e34ccf7aeca8d9883f85
BLAKE2b-256 dbd3d503a731103f4e005ec335f962085b9020147e751c806bccde06d8b48a06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page