3D Printer Status and Commands from/to Octoprint via HTTP REST API

For OH3 with the new http binding:
Items

// Octoprint
Group gOctoprint "Octoprint" (gAll)

String OctoprintPrinterState			"State [%s]"					                				(gOctoprint)	{channel="http:url:printer-connection:current_state"}
String OctoprintPrinterProfile			"Profile [%s]"					                                (gOctoprint)	{channel="http:url:printer-connection:printerProfile"}

String OctoprintPrinterCommand          "Printer Command"                                               (gOctoprint) 
String OctoprintSystemCommand           "System Command"                                                (gOctoprint) 

Number OctoprintJobEstimatedPrintTime	"Estimated Print Time [%.0f s]"	                <time>          (gOctoprint)	{channel="http:url:printer-job:estimatedPrintTime"}
String OctoprintJobFileName				"Filename [%s]"					                <text>          (gOctoprint)	{channel="http:url:printer-job:filename"}
Number OctoprintJobProgressCompletion	"Completion [%.0f %%]"					        <battery>       (gOctoprint)	{channel="http:url:printer-job:progress"}
Number OctoprintJobPrintTime			"Time Printed [%.0f s]"			                <time>	        (gOctoprint)	{channel="http:url:printer-job:printTime"}
String OctoprintJobPrintTimeString		"Time Printed [%s]"			                    <time>	        (gOctoprint)	
Number OctoprintJobPrintTimeLeft		"Time Left [%.0f s]"			                <time>	        (gOctoprint)	{channel="http:url:printer-job:printTimeLeft"}
String OctoprintJobPrintTimeLeftString  "Time Left [%s]"			                    <time>	        (gOctoprint)    
String OctoprintJobPrintETAString       "ETA [%s]"			                            <time>	        (gOctoprint)    
DateTime OctoprintJobPrintETADateTime   "ETA [%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]"    <time>          (gOctoprint)

String OctoprintPrinterPrintingState    "Printing State [%s]"								    		(gOctoprint)    {channel="http:url:printer-info:state"}
Number OctoprintPrinterHotEndTemp		"Nozzle temp [%.1f °C]"		                    <temperature>	(gOctoprint)	{channel="http:url:printer-info:temperature_bed_actual"}
Number OctoprintPrinterHotEndTempTarget	"Nozzle target [%.1f °C]"	                    <temperature>	(gOctoprint)	{channel="http:url:printer-info:temperature_bed_target"}
Number OctoprintPrinterBedTemp			"Bed temp [%.1f °C]"		                    <temperature>	(gOctoprint)	{channel="http:url:printer-info:temperature_hotend_actual"}
Number OctoprintPrinterBedTempTarget	"Bed target [%.1f °C]"							<temperature>	(gOctoprint)	{channel="http:url:printer-info:temperature_hotend_target"}

http.things

Thing http:url:printer-connection "3D Printer Connection" [ baseURL="http://octopi.yourdomain/api/connection?apikey=YOURAPIKEY", refresh=60] {
    Channels:
        Type string : current_state "Current State" [ stateTransformation="JSONPATH:$.current.state" ]
		Type string : printerProfile "Printer Profile" [ stateTransformation="JSONPATH:$.current.printerProfile" ]
}

Thing http:url:printer-job "3D Printer Print Job" [ baseURL="http://octopi.yourdomain/api/job?apikey=YOURAPIKEY", refresh=60] {
    Channels:
        Type number : estimatedPrintTime "Estimated Print Time" [ stateTransformation="JSONPATH:$.job.estimatedPrintTime" ]
		Type string : filename "Filename" [ stateTransformation="JSONPATH:$.job.file.name" ]
		Type number : filesize "Filesize" [ stateTransformation="JSONPATH:$.job.file.size" ]
		Type number : progress "Progress" [ stateTransformation="JSONPATH:$.progress.completion" ]
		Type number : filepos "Printed" [ stateTransformation="JSONPATH:$.progress.filepos" ]
		Type number : printTime "Time Printed" [ stateTransformation="JSONPATH:$.progress.printTime" ]
		Type number : printTimeLeft "Time Left" [ stateTransformation="JSONPATH:$.progress.printTimeLeft" ]
}

Thing http:url:printer-info "3D Printer Info" [ baseURL="http://octopi.yourdomain/api/printer?apikey=YOURAPIKEY", refresh=60] {
    Channels:
        Type string : state "Printing State" [ stateTransformation="JSONPATH:$.state.text" ]
		Type number : temperature_bed_actual "Temperature Bed Actual" [ stateTransformation="JSONPATH:$.temperature.tool0.actual" ]
		Type number : temperature_bed_target "Temperature Bed Target" [ stateTransformation="JSONPATH:$.temperature.tool0.target" ]
		Type number : temperature_hotend_actual "Temperature Hotend Actual" [ stateTransformation="JSONPATH:$.temperature.bed.actual" ]
		Type number : temperature_hotend_target "Temperature Hotend Target" [ stateTransformation="JSONPATH:$.temperature.bed.target" ]
}

3 Likes