A program that transfers info about Spoolman's data about the active Spool/Filament/Manufacturer to Klipper.
The program is a Moonraker agent that listens for notifications about changed spools. When the spool is changed, it asks spoolman about the changed spool's data and it asks Moonraker to run special gcode macros in Klipper for storing data about the new spool.
In the cloned repository's dir run:
python3 -m venv
venv/bin/pip3 install -r requirements.txt
When spool data is to be sent to Klipper, spool2klipper looks for gcode macros with the name
_SPOOLMAN_SET_FIELD_
fieldname. Ie:
_SPOOLMAN_SET_FIELD_filament_id
The macro will be called with the argument VALUE=
fields-value which stores the fieldname
and fields-value into the printer save_variables
.
When a new spool is loaded, or if the active spool is ejected, this agent will call
_SPOOLMAN_CLEAR_FIELDS
(if available) before storing new fields. This will ensure all previously
stored values are cleared in the event there are filaments with empty fields.
After all the macros have been called, a MSG will be sent to the terminal via
_SPOOLMAN_DONE
if available.
Add gcode macros to Klipper's config to receive and handle the fields you are interested in.
Here's a simple example:
[gcode_macro _SPOOLMAN_SET_FIELD_filament_id]
description: Store loaded filament's ID
gcode:
{% if params.VALUE %}
{% set id = params.VALUE|int %}
SAVE_VARIABLE VARIABLE=active_filament_id VALUE={id}
RESPOND MSG="Setting active_filament_id to {id}"
{% else %}
{action_respond_info("Parameter 'VALUE' is required")}
{% endif %}
[gcode_macro _SPOOLMAN_CLEAR_FIELDS]
description: Removes spool info
gcode:
SAVE_VARIABLE VARIABLE=active_filament_id VALUE=None
RESPOND MSG="Clearing active_filament_id"
[gcode_macro _SPOOLMAN_DONE]
description: The data was transferred
gcode:
RESPOND TYPE=command MSG="CHANGE FILAMENT"
Copy spool2klippper.service to /etc/systemd/system
, then run:
sudo systemctl start spool2klipper
sudo systemctl enable spool2klipper
To see its status, run:
sudo systemctl status spool2klipper
Moonraker can be configured to help upgrade spool2klipper.
Copy the the moonraker-spool2klipper.cfg
file to the same dir as where
moonraker.conf
is. Include the config file by adding:
[include moonraker-spool2klipper.cfg]
to Moonraker's config file (moonraker.conf).
This program was made to make it easier to use spoolman2slicer when not using nfc2klipper.
Pull requests are happily accepted, but before making one make sure the code is formatted with black and passes pylint without errors.
The code can be formatted by running make fmt
and checked with pylint
with make lint
.
If you add a new file, run "make reuse" to lint its licensing information.