Klipper / Moonraker binding for 3D Printer

I created a new binding for interfacing to 3D printers controlled with Klipper / Moonraker: arjanmels/openhab2-addons at am-feature-moonraker (github.com)

A compiled version can be found at: Release v1.0.0 of the Klipper/Moonraker binding · arjanmels/openhab2-addons · GitHub

For more information on Klipper: klipper | Klipper is a 3d-printer firmware (klipper3d.org)
For more information on the Moonraker Web API: Arksine/moonraker: Web API Server for Klipper (github.com)

Testing and feedback is most welcome.

2 Likes

Does this Plugin work in openhab 2? (link goes to openhab 2 plugins)
How does it work? Is there any examples oder documentation?
How do i use it?

Copy the .jar in openhab 2 addons-folder ends in:

2021-07-19 11:34:22.264 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.moonraker-3.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.moonraker [299]
Unresolved requirement: Import-Package: org.openhab.core.library.unit

at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Current version is for openhab 3. (Sorry my folder is indeed misnamed. If I find some time, I can probably make a OH 2 version without too much trouble, but next couple of week I am occupied.)

Would be great.
I tried upgrade my installation to version 3 … but after this openhab starts anymore.

I need a clean openhab 3 installation and migrate all my things step by step. This took some time.

I’m also very interested in the documentation, how to use it with Klipper (Voron)

I have OH3:

2021-07-19 21:09:18.740 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.moonraker-3.1.0-SNAPSHOT.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.moonraker [320]

  Unresolved requirement: Import-Package: javax.measure; version="[1.0.0,2.0.0)"
	at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.16.200.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:440) ~[org.eclipse.osgi-3.16.200.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.8]

I recompiled the version @arjanmels provided to fix your error (got the same)

I tested it yesterday with one (incomplete) print. For me it looks good.

Jar can be found here:

1 Like

I also found out, that you can enable MQTT at moonraker, so this binding is not needed if someone prefers MQTT.

I don’t have tested it much but it looks like an good alternative.

Do you a smal example, how to use the binding? I’m using a Voron 2.4 with Klipper.

Did you just need to recompile, or did you need to change anything?

All changed where made in MoonrakerHandler.java

I had to replace following Import:

import tec.uom.se.unit.Units;

with

import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;

And use SIUnits for CELSIUS and METRE

Also added following to public void onEvent to catch an warning about a missing method:

            case "notify_proc_stat_update":
                return;

I have installed Klipper and Moonraker via KIAUH

Afterwards i configured the Binding via GUI in Openhab (i’m on the newest Milestone Build for 3.2)

After dropping the jar at my openhab system, i added a new Thing via GUI:

And only had to configure the IP Adress of the Raspberry connected to my Printer (i never changed the port on the Raspberry with Klipper/Moonraker)

After creation of the Thing i added an Equipment with some of the given Channels:

An Description of the channels (apparently the name of the channels is not exactly the same as in the Moonraker documentation) can be found here Moonraker documentation

Newbie-question: In which folder I have to drop the JAR?

See here: Through manually provided add-ons

1 Like

I copied/renamed the JAR into the addons folder /usr/share/openhab/addons, on PI4, but the binding does not appear in the Binding list of the UI. Also not after restart/reboot

@OH3:/usr/share/openhab/addons $ ls -l
insgesamt 236352
-rw-r--r-- 1 openhab openhab     36840 Okt 12 08:37 moonraker-3.2.0.jar
-rw-rw-r-- 1 openhab openhab 241979494 Jun 27 22:57 openhab-addons-3.1.0.kar
-rw-rw-r-- 1 openhab openhab        70 Jun 27 22:57 README

I’m using OH3.1. Is V3.2 mandatory?

As written many times before, manually installed bindings will not show up in the list of installed bindings. You need to go to Things menu, press the big blue button with + symbol and select the appropriate binding.

1 Like

Thank you, I successfully created the Thing.

Connection to Moonraker Webservice was closed abnormally (code: 1006). Reason: NullPointerException

I keep getting this error and the thing is switching between online/offline every second.

Anyone knows what this could be?

Hi!

Under Openhab 3.3.0-SNAPSHOT I was unable to load binding. The following error occured in logs:

2022-01-16 12:18:02.068 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.moonraker-3.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.moonraker [293]
  Unresolved requirement: Import-Package: javax.measure; version="[1.0.0,2.0.0)"
	at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.16.300.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.16.300.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.7.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.7.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.7.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.7.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.7.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.7.2]

I have only installed:

openhab> bundle:list -s | grep javax
 52 │ Active    │  80 │ 3.5.7                 │ javax.jmdns
 53 │ Active    │  80 │ 2.1.3                 │ javax.measure.unit-api
 58 │ Active    │  80 │ 1.0.1                 │ org.apache.aries.javax.jax.rs-api
 87 │ Active    │  80 │ 1.0.0.2               │ org.apache.servicemix.bundles.javax-inject

Thank you.
Zsolt.

I think i found a fix for this, please try the new release found here:
Bugfix Reconnect Release

If it is still not working, i will need debug logs of openhab.