Package: busylight-for-humans
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.Flag1,
Busylight Alpha2,
Status Indicator3,
Blink(1)4,
Mute5,
Blynclight6.
Orb7,
BusyLight Omega8,
BlinkStick Square9,
Blynclight Mini10,
MuteMe Original11,
fit-statUSB12,
MuteSync13,
Blynclight Plus14FeaturesControl lights from thecommand-line.Control lights via aWeb API.Importbusylightinto your own Python project.Supported on MacOS and LinuxWindows support is untested but there are reports that it is working.Supportsninevendors & sixteen devices:VendorAgile InnovativeBlinkStick SquareCompulabfit-statUSBEmbravaBlynclightBlynclight MiniBlynclight PlusKuandoBusylight AlphaBusyLight OmegaLuxaforBluetoothFlagMuteOrbPlantronicsStatus IndicatorMuteMeMuteMe OriginalMute MiniMuteSyncMuteSyncThingMBlink(1)If you have a USB light that's not on this list open an issue with:the make and model device you want supportedwhere I can get oneany public hardware documentation you are aware ofOr even better, open a pull request!GratitudeThank you to@todbotand the very nice people atThingMwho
graciously and unexpectedly gifted me with twoblink(1) mk3lights!Basic InstallInstalls only the command-linebusylighttool and associated
modules.$python3-mpipinstallbusylight-for-humansWeb API InstallInstallsuvicornandFastAPIin addition tobusylight:$python3-mpipinstallbusylight-for-humans[webapi]Development InstallI use the toolpoetryto manage various aspects of this project, including:dependenciespytest configurationversioningoptional dependenciesvirtual environment creationbuilding packagespublishing packages to PyPi$python3-mpipinstallpoetry$cdpath/to/busylight$poetryshell<venv> $ poetry install -E webapi<venv> $ which busylight<venv> $ which busyserveAfter installing into the virtual environment, the project is now available in editable mode.  Changes made in the source will be reflected in the runtime behavior when running in the poetry initiated shell.Linux Post-Install ActivitiesLinux controls access to USB devices via theudev 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:$busylightudev-rules-o99-busylights.rules$sudocp99-busylights.rules/etc/udev/rules.d$sudoudevadmcontrol-R$# unplug/plug your light$busylightonCommand-Line Examples$busylighton# light turns on green$busylightonred# now it's shining a friendly red$busylighton0xff0000# still red$busylighton#00ff00       # now it's blue!$busylightblink# it's slowly blinking on and off with a red color$busylightblinkgreenfast# blinking faster green and off$busylight--allon# turn all lights on green$busylight--alloff# turn all lights offHTTP API ExamplesFirst start thebusylightAPI server using thebusyservcommand line interface:$busyserve-DINFO:     Started server process [40064]INFO:     Waiting for application startup.INFO:     Application startup complete.INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)...The API is fully documented and available via these URLs:https://localhost:8000/redochttps://localhost:8000/docsNow you can use the web API endpoints which return JSON payloads:$curl-shttp://localhost:8000/lights/status|jq...$curl-shttp://localhost:8000/light/0/status|jq...$curl-shttp://localhost:8000/light/0/on|jq{"light_id": 0,"action": "on","color": "green","rgb": [0, 128, 0]}$curl-shttp://localhost:8000/light/0/off|jq{"light_id": 0,"action": "off"}$curl-shttp://localhost:8000/light/0/on?color=purple|jq{"light_id": 0,"action": "on","color": "purple","rgb": [128, 0, 128]}$curl-shttp://localhost:8000/lights/on|jq{"light_id": "all","action": "on","color": "green","rgb", [0, 128, 0]}$curl-shttp://localhost:8000/lights/off|jq{"light_id": "all","action": "off"}$curl-shttp://localhost:8000/lights/rainbow|jq{"light_id": "all","action": "effect","name": "rainbow"}AuthenticationThe API can be secured with a simple username and password throughHTTP Basic Authentication. To require authentication
for all API requests, set theBUSYLIGHT_API_USERandBUSYLIGHT_API_PASSenvironmental variables before runningbusyserve.:warning:SECURITY WARNING: HTTP Basic Auth sends usernames and passwords incleartext(i.e., unencrypted). Use of SSL is highly recommended!Code ExamplesAdding light support to your own python applications is easy!Simple Case: Turn On a Single LightIn this example, we pick an Embrava Blynclight to activate with
the color white.frombusylight.lights.embravaimportBlynclightlight=Blynclight.first_light()light.on((255,255,255))Not sure what light you've got?frombusylight.lightsimportUSBLightlight=USBLight.first_light()light.on((0xff,0,0xff))Slightly More ComplicatedThebusylightpackage includes a manager class that's great for
working with multiple lights or lights that require a little
more direct intervention like the Kuando Busylight family.frombusylight.managerimportLightManagerfrombusylight.effectsimportEffectsmanager=LightManager()forlightinmanager.lights:print(light.name)rainbow=Effects.for_name("spectrum")(duty_cycle=0.05)manager.apply_effect(rainbow)...manager.off()