Skip to content

Add a Moonraker backend for Klipper printers - #2

Merged
PyFlat-JR merged 2 commits into
mainfrom
feature/moonraker
Oct 8, 2026
Merged

PyFlat-JR merged 2 commits into
mainfrom
feature/moonraker

Conversation

@PyFlat-JR

Copy link
Copy Markdown
Member

What does this PR do?

Adds a Moonraker backend, so Klipper printers running Mainsail or Fluidd work like OctoPrint ones.

  • Setup: the address step recognizes Moonraker from /server/info, which OctoPrint does not answer (Moonraker answers OctoPrint's /api/version, so that alone would not tell them apart). No sign-in when this computer is one of Moonraker's trusted_clients, otherwise Moonraker's API key, stored as a secret. Without a name the printer takes the host name of the machine running Klipper.
  • Live state: everything after setup goes over Moonraker's JSON-RPC websocket. Klippy's state comes from server.info and the notify_klippy_* notifications, the printer objects from a subscription that only sends changed fields (MoonrakerStatus.Merge).
  • Events: Klipper has no job events, so they follow from print_stats.state changing.
  • Heaters: extruder, extruder1 and heater_bed, and a chamber as heater_generic chamber (settable) or temperature_sensor chamber (read only).
  • Actions: job control, files, temperatures, G-code, motion and system commands (firmware restart, Klipper and Moonraker restart, host reboot and shutdown). G-code waits 1 s for a refusal and then answers sent, since printer.gcode.script only returns once the G-code ran.
  • Lights: Moonraker's power devices, as outputs power-<device>. They have no change notification, so they are read every 2 s while there are any.
  • Webcam: the first enabled MJPEG webcam Moonraker lists. WebRTC and HLS streams cannot be shown; the address step's advanced settings take an MJPEG address instead.
  • Not supported: connecting and disconnecting the printer (Klipper does not do that) and temperature presets. Start and Restart print the last loaded file again, and Print a file always starts the print.
  • New backend id moonraker. FakeMoonraker is a Kestrel fake of the HTTP info endpoints and the websocket, and the backend passes the shared BackendContract plus its own MoonrakerTests.
  • README (supported table, setup, Privacy) and the manifest description name Moonraker.

Checklist

  • I have read AGENTS.md.
  • dotnet build and dotnet test pass locally (0 warnings, 188 tests).
  • I updated README.md / AGENTS.md if this changes what they describe.
  • If this touches a printer backend: I tested it against a real server (see below).

Printer/server tested against (if applicable)

Not yet on a real Klipper printer here. Written against the documented API (https://moonraker.readthedocs.io) and the fake. It ships to a closed tester group with Klipper printers first, through the Creator Portal, before a public release.

@PyFlat-JR
PyFlat-JR merged commit 71f96d7 into main Oct 8, 2026
3 checks passed
@PyFlat-JR
PyFlat-JR deleted the feature/moonraker branch October 8, 2026 17:25
@PyFlat-JR PyFlat-JR linked an issue Oct 8, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Klipper / Mainsail integration ?

1 participant