https://github.com/fmartingr/pyluxafor
Simple helper library and CLI to interact with luxafor products
https://github.com/fmartingr/pyluxafor
cli led luxafor python python3
Last synced: about 1 year ago
JSON representation
Simple helper library and CLI to interact with luxafor products
- Host: GitHub
- URL: https://github.com/fmartingr/pyluxafor
- Owner: fmartingr
- License: mit
- Created: 2017-01-17T20:26:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-04-01T01:35:35.000Z (about 4 years ago)
- Last Synced: 2025-03-25T15:35:08.459Z (over 1 year ago)
- Topics: cli, led, luxafor, python, python3
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyluxafor
Helper interface and CLI to interact with [luxafor](https://luxafor.com) products.
## Install
```
git clone git@github.com:fmartingr/pyluxafor.git
cd pyluxafor
python3 setup.py install
```
## Ensure that USB device gets proper permissions
Create UDEV rule in /etc/udev/rules.d/60-luxafor.rules with the following content
```
# add Luxafor LED flag
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d8", ATTR{idProduct}=="f372", MODE:="0666"
```
Reload udev configuration files
```shell
sudo udevadm control --reload && sudo udevadm trigger
```
Reinsert the Luxafor LED light.
## Using the CLI
Pyluxafor provides the `luxa` command to interact with the USB led in the same way as the library
does, with some helper commands to convert colors between RGB/Hex.
```
# Converts between hexadecimal to decimal color notations
luxa hex2dec 00ff00
luxa dec2hex 255 255 0
# Set a flag with a fixed color
luxa set --led=all #ff0000
# Fade
luxa fade --led=all --speed=10 #00ff00
# Strobe
luxa strobe --led=front --speed=100 --repeat=10 #0000ff
# Wave
luxa wave --wave 3 --duration=100 --repeat=200 #ff0000
# Pattern
luxa pattern --repeat=2 2
# Turns off the luxafor
luxa off
# Using the conversion helpers in one command
luxa set $(luxa dec2hex 255 0 0)
```
## Using as a library
``` python
from luxafor import luxafor
lux = luxafor.Luxafor()
# Led types
luxafor.Leds.ALL
luxafor.Leds.FRONT
luxafor.Leds.BACK
luxafor.Leds.LEDn # Where n is a number from 1 to 6, refer to the class
# Set a basic color
# From: off, yellow, green, blue, magenta, cyan, red, white
lux.set_basic_color('green')
# Set a static color
lux.set_color(, , , )
# Fade to a color
lux.fade(, , , , )
# Strobe
lux.strobe(, , , , , )
# Wave
# Wave types:
# 1: Short wave
# 2: Long wave
# 3: Overlapping short wave
# 4: Overlapping long wave
lux.wave(, , , , , , )
# Enable predefined pattern
# Patterns from 1 to 8
lux.pattern(, )
# Turn off the luxafor
lux.turn_off()
```