3D Printer Status from Octoprint via MQTT

Got it.
if (OctoprintShutdownAfterPrint.state == ON && OctoprintJobProgressCompletion.state.toString == "100.0 %"){

is my Solution.

Thanks.
– Chris

some to help me?
i can’t write the JSONPATH where the printer go in pause when the filament is end. I need a item that notice pause state.

Switch printpause	                "pause             "		<network>          (gOctoprint)	    {mqtt="<[mosquitto:octoprint/progress/printing:state:JSONPATH($.state.Printing.paused)]"}

thanks

I managed to write the correct path, I think, but he doesn’t see when he pauses for fine filament

String printpause	                "pause  [%s] "		    <network>          (gOctoprint)	    {mqtt="<[mosquitto:octoprint/progress/printing:state:JSONPATH($.printer_data.state.flags.pausing)]"}

i’m not able to do this.

Octopilog says it is connected to the mqtt server.

New MQTT Binding installed in OH2 (aka MQTT 2.4) in place
JSONPATH Transformation installed in OH2 in place

I reduced the item/things files to reduce mistake .things:

Thing mqtt:topic:octoprint "Octoprint MQTT" (mqtt:broker:127_0_0_1_1883) {
Channels:
    Type string : connected "Connected" [ stateTopic="octoprint/mqtt" ]

.items:
Group gOctoprint “Octoprint” (gAll)
// MQTT
String OctoprintConnected “Connected [%s]” (gOctoprint)
{channel=“mqtt:topic:octoprint:connected”}

Frame {
		Text	item=OctoprintConnected
			}`        

logtail says : Cannot retrieve item ‘OctoprintConnected’ for widget org.eclipse.smarthome.model.sitemap.Text

what do i do wrong ?

Errors in the log when you save the files or any other errors?

Nope, not that i can find, i tried the other method of getting info from the printer (via HTTP REST API). That works. It just irretate’s me that it does not work through MQTT

This is not an MQTT issue. The error is coming from your sitemap. Either there is a problem in your sitemap (NOTE, is that stray ` from your code above in your actual sitemap file?) or there is a problem in your .items file preventing it from loading that Item.

Hi,
has anyone managed to detect a printing pause? Unfortunately the MQTT plugin delivers “printing” as state then. Pauses could happen when either the filament runout sensor triggered or a M600 command comes along in the gcode. Typically, the bed stays heated and the nozzle heating is being switched off.
I tried several combinations but I was unlucky so far…

Im using the 2.4 broker

is the thing file example right for this ?

in paper ui its saying bridge uninitialized

Ive changed the Mqtt statement to

Bridge mqtt:broker:myUnsecureBroker [ host=“192.168.1.100”, secure=false]
{
and its now staying its online in the things section but I’m not getting any readings in the control section

just getting NaN for the values

fixed it in the P in octoPrint is not upper case

there is my new things file which works incase it helps anyone else

Bridge mqtt:systemBroker:embedded-mqtt-broker “my Broker” [ host=“...”, secure=false]
{
Thing mqtt:topic:octoprint {

Channels:
    Type string : connected "Connected" [ stateTopic="octoPrint/mqtt" ]
    Type string : state "State" [ stateTopic="octoPrint/event/PrinterStateChanged", transformationPattern="JSONPATH:$.state_string" ]
    Type string : event "Event" [ stateTopic="octoPrint/event/+", transformationPattern="JSONPATH:$._event" ]
    Type string : filename "Filename" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.job.file.name" ]
    Type number : progress "Progress" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.completion" ]
    Type number : printTime "Time Printed" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.printTime"$
    Type number : printTimeLeft "Time Left" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.printTime$
    Type number : layerheight "Layerheight" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.currentZ" ]
    Type number : temperature-bed-actual "Temperature Bed Actual" [ stateTopic="octoPrint/temperature/bed", transformationPattern="JSONPATH:$.actual" ]
    Type number : temperature-bed-target "Temperature Bed Target" [ stateTopic="octoPrint/temperature/bed", transformationPattern="JSONPATH:$.target" ]
    Type number : temperature-hotend-actual "Temperature Hotend Actual" [ stateTopic="octoPrint/temperature/tool0", transformationPattern="JSONPATH:$.act$
    Type number : temperature-hotend-target "Temperature Hotend Target" [ stateTopic="octoPrint/temperature/tool0", transformationPattern="JSONPATH:$.tar$

}
}

1 Like

Can you share your whole file or content? I cannot get it to run.
When I tried and stitched your code together I get an error:

Provide a thing type ID and a thing ID in this format:

I currently have the code look like the following, but it’s not working.

Bridge mqtt:systemBroker:embedded-mqtt-broker "openHabMQTT" [ host="localhost:1883", secure=false ]
    { Thing topic octoPrint "MQTT Thing" {
        Channels:
            Type string : connected "Connected" [ stateTopic="octoPrint/mqtt" ]
            Type string : state "State" [ stateTopic="octoPrint/event/PrinterStateChanged", transformationPattern="JSONPATH:$.state_string" ]
            Type string : event "Event" [ stateTopic="octoPrint/event/+", transformationPattern="JSONPATH:$._event" ]
            Type string : filename "Filename" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.job.file.name" ]
            Type number : progress "Progress" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.completion" ]
            Type number : printTime "Time Printed" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.printTime" ]
            Type number : printTimeLeft "Time Left" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.progress.printTimeLeft" ]
            Type number : layerheight "Layerheight" [ stateTopic="octoPrint/progress/printing", transformationPattern="JSONPATH:$.printer_data.currentZ" ]
            Type number : temperature_bed_actual "Temperature Bed Actual" [ stateTopic="octoPrint/temperature/bed", transformationPattern="JSONPATH:$.actual" ]
            Type number : temperature_bed_target "Temperature Bed Target" [ stateTopic="octoPrint/temperature/bed", transformationPattern="JSONPATH:$.target" ]
            Type number : temperature_hotend_actual "Temperature Hotend Actual" [ stateTopic="octoPrint/temperature/tool0", transformationPattern="JSONPATH:$.actual" ]
            Type number : temperature_hotend_target "Temperature Hotend Target" [ stateTopic="octoPrint/temperature/tool0", transformationPattern="JSONPATH:$.target" ]
    }
}

running the latest openhabian and updated to the latest octoprint by clean install and restore backup.I cant make octoprint mqtt to talk to openhab anymore.My settings (things ,items etc) are all the same but i get “disconnected” on octoprint/mqtt topic.Any ideas?Of course all my other mqtt items ,other than octoprint ,they run ok.

Have you checked the “octoprint” vs “octoPrint” (capital P) in the stateTopic? It has changed in octoprint mqtt plugin.

yeap checked , my main topic is

octoprint/

the same as in my octoprint mqtt plugin.

Did you try to use a tool like mqtt.fx and see if the mqtt messages are actually arriving at the broker?

using mqtt.fx and subscribe to topics like “octoprint/temperature/bed” or “octoprint/mqtt” i get only the last retained value,so i thing the problem is at octoprint side…

You can use a # to see all messages on the broker. If there is nothing from octoprint, then check the connection between octoprint and broker!

found it ! i disabled Plugin blacklist processing feature at octoprint + checked the “Clean session” option at mqtt plugin,restarted and mqtt started working…

1 Like

Could you be so kind and share your things file for the MQTT settings?
Are you using the embedded MQTT broker?