控制USB连接的LED灯,就像人一样。
busylight-for-humans的Python项目详细描述
BusyLight for Humans™使您可以控制USB连接的LED 各种各样的小贩送来的灯。灯光可以通过 命令行,使用httpapi或直接导入到自己的命令行中 python项目。需要一盏灯让你知道什么时候有个主人,或者 什么时候狗想出去?一盏指示“请勿打扰”的灯怎么样?在
这种可能性是无限的。在
从后到前,从左到右
BlyncLight、BlyncLight Plus、Busylight
闪烁(1)、标志、闪烁棒
特点
- 通过Command-Line控制灯
- 通过Web API控制灯
- 支持来自五家供应商的光源
- 敏捷创新
- Embrava Blynclight公司
- 宽多商务灯
- 卢萨福旗
- ThingM闪烁1
- 支持MacOS,Linux,可能还有Windows和BSD!在
- 广泛测试树莓皮3b+,零W和4
基本安装
$ python3 -m pip install busylight-for-humans
Web API安装
除了busylight
,还安装uvicorn
和{
Linux安装后活动
Linux通过udev子系统控制对USB设备的访问,默认情况下拒绝非root用户访问它无法识别的设备。我掩护你!在
配置udev规则时需要具有root权限:
$ 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
命令行示例
$ 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示例
首先启动busylight
API服务器:
$ 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)
API已经有了完整的文档并且可以在@
现在,您可以使用返回JSON有效负载的web API端点:
$ curl http://localhost:8888/1/lights $ curl http://localhost:8888/1/lights/on $ curl http://localhost:8888/1/lights/off $ curl http://localhost:8888/1/light/0/on/purple $ curl http://localhost:8888/1/light/0/off $ curl http://localhost:8888/1/lights/on $ curl http://localhost:8888/1/lights/off $ curl http://localhost:8888/1/lights/rainbow
- 项目
标签: