[RELEASE] Klipper/Moonraker 3D Printer Driver

It's Moonraker so the front end doesn't matter, is your generated GCode in a folder by any chance rather than in the main directory? I suspect that's the problem looking at the API docs, but can't remember if my code accounts for paths..

Here's my trigger BTW, much simpler and just passes on the variables rather than coding all the scenarios

Checkout the "Get Printer Status" section and the flags listed, I think these are all of them returned to the "text" field as "state", however I have added an additional change state of "Complete" which only exists for 1 cycle when it changes from Printing to Operational, which should only apply when there is a successful completion..

https://moonraker.readthedocs.io/en/latest/web_api/

EDIT: I can fix the errors (or at least get them to fail gracefully), there is also a bug that means the error can stop the device checking for updates, I will need to take a look at the filename issue though and see if I can extract the path from the API to append to the call

1 Like

My printer uses the default Mainsail config:

[virtual_sdcard]
path: ~/gcode_files
on_error_gcode:
  CANCEL_PRINT

I did have something similar, however my 1 min poll time missed the transition from "Complete" to "Operational". I also wanted to customise my notifications and found this worked well:

Ah, I have found that bug, I thought it was PEBKAC on my part. :rofl:

Btw, I may have found another bug

I get a lot less info out of my Mega Zero:
Screenshot 2023-01-20 at 9.41.00 am

Than I do from my Adventurer 3:

Screenshot 2023-01-20 at 9.41.13 am

Both are running the same Mainsail version and have the detailed option enabled.

The gcode question was more about where you save them to, are they in the root directory or have you created sub folders to put in your gcode? I expect folders are the problem.

I didn’t get time to sort this evening, so will be over the weekend now, your other issue is related to not being able to resolve the gcode location, as it’s looking up info on the gcode not the printer

1 Like

I send them direct to my printer via IP from SuperSlicer, Mainsail stores them as per the below config. Both printers use the stock config:

It’s more about what’s in that folder, but based on what you are saying it’s likely in the root of that folder. Likely something SS related, I’m using cura so it give that a go and see if I can replicate

Dude, how do you use that abomination? :scream:

:wink:

It should always go through this status as it's the one I've added it's actually a detection of a change from printing to operational, so will show as complete for 1 minute if that is your poll time..

I can't figure out your filename issue right now, but have uploaded V0.9 fixing the other issues, will need to look in to it a bit later..

1 Like

Maybe it is due to the stop polling bug. I'll try your update and see how it goes.

Here's a file from my slicer to see if that helps:

https://www.dropbox.com/s/alhsbg76lk33h13/X%20Carriage%20HSI-Mega%20Zero%200.4mm-eSun%20ABS%2B.gcode?dl=0

https://www.dropbox.com/s/t3ub5evmlfvefds/X%20Carriage%20HSI.3mf?dl=0

I expect the issue is the + in the file name, as needs to be converted to %2B if in a path.. V0.10 uploaded give it a go otherwise I'll need to replicate later

1 Like

Appreciate your efforts mate, I maintain the Wunderground Driver, so I know how much fun it is to squash all the bugs! :sunglasses:

EDIT: Nice work, that solved the issue of the missing Current State data and the errors in the logs:

Screenshot 2023-01-20 at 9.05.44 pm

1 Like

Glad it worked, yeah this one wasn't my best work, I initially just threw it together to get a print completion alert, but then added a few more calls on request and didn't really sort out the error handling properly, so was all a bit of a bodge..

I've done a couple of others too Plex Communicator is the main one

I'll take a look at WU if I need to get the weather side setup again, I'm sure I used to run it but that might have even been in the old SmartThings days, whatever I was running last closed down the API might have been Dark Sky maybe.

EDIT: Just to say, the option to pull extra information will increase the load and spam the logs as you'll get time updates every refresh etc.. so only enable that option if you really need it..

1 Like

So far your fixes seem to have resolved the poll failure issue too. I’m actually getting reliable notifications now.

I eventually settled on this rule config (status changes as the trigger):

I could use %device% but because I have 2 printers, and prefix the device name with “Printer:”, this keeps the notification more concise.

1 Like

Howdy, I’m still finding that the 1 minute poll time can miss the window where the status is “Complete”.

If this status is coming from moonraker, Is there a different field we can get an useful status from?

“Operational” is never shown as a status via the front end, not even via apps like Mobileraker.

NVM, I found a workaround - Print Percent = 100 + Switch off:

Like I said it doesn't come from Moonraker, it's not a polled state so can't be "missed", it just checks previous and current status and if they match then updated to Complete for 1 cycle..

Can you please check your logs and tell me what statuses are being reported, before and after including capitalisation and I'll re-check the transition code, if it's not working it's likely a gap in the code I hasn't considered..

Will do, I'm off to bed now, but I'll check it tomorrow.

1 Like

Just wanted to say THANK YOU for this driver...just amazing to have my printer connected in about two minutes! Thanks for providing this, just great stuff.

I do have one question - where does "Print File Name" pull from? I assume it allows you to print existing files on Klipper that have already been uploaded, but can't pull from anywhere else, or ?

image

1 Like

No problem!

My assumption is local only, the api doesn’t actually say, api details here, just look at the Print a file section:

https://moonraker.readthedocs.io/en/latest/web_api/

1 Like

Thanks!

It's there a way to get RM to send a notification with the filename in it?

I tried using %filename% but that didn't work, results in "null" in the message.

Any other options?