Notifications
Clear all

REST API for XL tools?  

  RSS
luma
 luma
(@luma)
Member
REST API for XL tools?

I'm wading through what I think is the REST API spec and trying to figure out how to get information about the currently selected tool on a 5XL and nothing I'm hitting seems to have that detail.  What would be even better would be a way to know which tools are selected for a given job and some way to work out what sort of filament is being used for each.

Anyone have any idea how one might get this done?

Posted : 14/03/2025 7:12 pm
Jav.BR liked
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE: REST API for XL tools?

I don't have XL but I think it may not be available via web API.

You have higher chances of getting it via syslog metrics under 'active_extruder' number.

See https://github.com/nvtkaszpir/3d-print/tree/main/prusa3d-metrics-list

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/03/2025 9:05 am
luma liked
luma
 luma
(@luma)
Member
Topic starter answered:
RE: REST API for XL tools?

I gotta be honest - I'm not quite sure what to do with that.  When you say "syslog" I'm thinking of a remote logging facility - is that a thing with these printers?

Posted : 15/03/2025 3:04 pm
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE:

Official docs says how to do it https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/doc/metrics.md and yeah, it's not that easy.

In short it would require to set up syslog listening server. 
The good news is that they provide docker-compose file which can set up listening syslog server within minutes.

Then you need to instruct the printer to send syslog messages to that server.
It consists of adding gcode commands to enable logging to remote host and what metrics to send - in for example start gcode section.

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/03/2025 3:48 pm
luma liked
luma
 luma
(@luma)
Member
Topic starter answered:
RE:

Roger that - super cool that syslog export is built straight into the firmware! I have a syslog host here but I'm trying to get this all working in Home Assistant which doesn't have any way to surface that info in realtime.  I'll keep hunting, thanks for the help!

 

edit: maybe have a hacky solution - syslog-ng supports export to MQTT which I can then pickup in HA.  Going to take some hacking but workable maybe?

It'd be a lot easier if this info was available via REST 😀

Posted : 15/03/2025 4:09 pm
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE:

Hm maybe syslog-ng bridge to mqtt could work, haven't tried. I would rather try to do some metrics system -> HA bridge via queries executed once per second or minute maybe, no need to flood HA with printer metrics every 100ms...

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/03/2025 4:36 pm
luma liked
luma
 luma
(@luma)
Member
Topic starter answered:
RE: REST API for XL tools?

Finally got a working solution!  As noted above, I've been trying to figure out which tool heads and materials are in use for a print as it starts, so I can set my the correct filament dryers to the appropriate setting.  For example, if I start a job with PLA on head 2 and PETG on head 5, turn on dryers 2 and 5 with the correct temperature for each (and then hey let's turn the lights on in those two so I can see how much filament is left, what color is loaded, etc).

Here's what eventually worked:

  1. Home Assistant PrusaLink integration maintains a connection to the local REST interface on the XL
  2. Tuya-Local custom component connected to 5 GratKit Firefly filament dryers, devices named as filament01 through filament05
  3. Create a command_line sensor to pull current job details and have it update when the printer goes to state "Printing"
  4. Create an automation to read that sensor, turn on the correct filament dryers, and set the appropriate material (which will set the temp etc on the dryer)
  5. Optionally, create a simple automation that'll turn all the dryers off when the job goes to state "Finished"

The end result is fully automatic - I shoot a file over from PrusaSlicer, printer gets started warming up, few seconds later the correct filament dryers turn themselves on with the correct settings.

I should note that this might only work with PrusaSlicer.  I couldn't find a REST command that'll tell me what tools and materials are in use, so instead this will download the currently-printing GCODE to pry some metadata out of the job which PS will put there by default, and is plaintext for both GCODE and BGCODE jobs.

 

 

Posted : 25/04/2025 12:56 pm
luma
 luma
(@luma)
Member
Topic starter answered:
RE: REST API for XL tools?

Got it all stitched together!  Now when I send a job to the printer the dryers that will be used are lit up and have the configured material displayed on the LCD, making it clear which spools are in use and what the printer is expecting to be in each. 

 

Posted : 27/04/2025 1:30 pm
LarGriff
(@largriff)
Reputable Member
RE:

Very impressive!  I just wish I understood it all!  Thanks for sharing your solution.

MK4S/MMU3

Posted : 27/04/2025 1:40 pm
Share: