Currently it is easy to send data from klipper to API clients, but there is no general mechanism for sending data in the other direction.
I use Spoolman to manage my spools and I autogenerate my filament configuration in the slicers so they’ll have a “filament_start_gcode” code that verifies the filament.
I also have a program that sets the spool id and filament id in klipper (via gcodes submitted via moonraker’s API) whenever I load a new spool.
This works fine, but if I switch spools in the frontend, then the filament id is not changed.
Currently moonraker will load the spool’s data from Spoolman when switching spools, but it has no way to tell klipper about that (except by calling gcode).
Maybe there could be a new API endpoint where API clients can set a variable to a json value or object and those becomes available to gcode macros? Then moonraker could set “moonraker.spool” to the returned data from Spoolman about the active spool and my gocde macro could use “SOMETHING.moonraker.spool.filament.id” when it wants to know about the loaded filament.
I’ve seen feature requests for moonraker about being able to access other Spoolman spool data as well. This would work for them too.
This could of course be used for other clients and their data as well.
I can try to implement this if this is something that would fit in klipper.