This script will take the printer status from Klipper/Moonraker and apply different effects to a WS281x LED strip.
The code has been migrated from the OctoPrint-WS281x_LED_Status (https://github.com/cp2004/OctoPrint-WS281x_LED_Status) plugin to work with Klipper.
sudo apt update && sudo apt install -y git
sudo pip3 install requests PyYAML RPi.GPIO rpi_ws281x adafruit-circuitpython-neopixel
cd /home/pi
git clone https://github.com/11chrisadams11/Klipper-WS281x_LED_Status.git
cd Klipper-WS281x_LED_Status
chmod 744 ./klipper_ledstrip.py
./klipper_ledstrip.py
systemctl daemon-reload
to enable the servicesystemctl enable ledstrip
to have the service start on bootsystemctl start ledstrip
to start the servicesystemctl restart ledstrip
to restart the ledstrip service./klipper_ledstrip.py <red> <green> <blue> <brightness:optiona>
Example:
./klipper_ledstrip.py 255 255 255 255 ## Full brightness white
./klipper_ledstrip.py 255 0 0 ## Red with default brightness specified in the script
Add custom entries to printer.cfg
[gcode_shell_command led_off]
command: ./home/pi/my_klipper_ledstrip.py 0 0 0
timeout: 2.
verbose: True
[gcode_shell_command led_white]
command: ./home/pi/my_klipper_ledstrip.py 255 255 255
timeout: 2.
verbose: True
[gcode_shell_command led_purple]
command: ./home/pi/my_klipper_ledstrip.py 255 0 255
timeout: 2.
verbose: True
[gcode_macro LED_OFF]
gcode:
RUN_SHELL_COMMAND CMD=led_off
[gcode_macro LED_WHITE]
gcode:
RUN_SHELL_COMMAND CMD=led_white
[gcode_macro LED_PURPLE]
gcode:
RUN_SHELL_COMMAND CMD=led_purple
rpi_ws281x library instructions for needed changes depending on GPIO pin used: https://github.com/jgarff/rpi_ws281x