Octoprint Server device handler

I have created a SmartApp & Device Handler for controlling and monitoring a 3d printer connected to an Octoprint server. (Octoprint is a free server platform that can easily be installed on a Raspberry Pi or PC.) To install my App/DTH, add my GitHub repo and add the SmartApp code and the Device Handler code in the IDE.

Username: karatecarter
Repo: Octoprint-Server

In the ST classic app just install the SmartApp and add a new server. Enter the IP, Port, and API Key for the server (you can get your API key by launching the web app and going to settings) and hit done and save. Then you can optionally come back into the app and link a power switch for your printer, and also link extra power switches to turn on/off with the printer (ex. if you have a light that you want to turn on/off with the printer. In the device handler, you will see there is an auto off switch which will automatically turn off the connected switches after a print completes.

Note that this relies on polling which I currently only have it doing once a minute, so status updates aren’t immediate, but you can always hit the refresh button to get an update.

5 Likes

Thanks Soo much for this.

Been wanting this for 2.5 years. :slight_smile:

Glad to help, I was surprised no one had already done this. Let me know what you think.

Liking it so far, I was doing prints on both machines last night and both popped right up.

Now I only have one other device not in ST due to no DTH*there is an API but integrating it into ST is beyond my skill set.). So I’m a happy camper.

I posted this to Hubitat but it isn’t working…

These are my logs:
app:9152020-03-14 12:19:05.912 pm tracePrinter settings for [request:printerSettings, printer:null, isNew:true]

app:9152020-03-14 12:16:35.927 pm debugInitializing

app:9152020-03-14 12:16:35.922 pm tracePrinter settings for [request:printerSettings, printer:null, isNew:true]

app:9152020-03-14 12:16:34.268 pm debugInitializing

Any suggestions?

What is happening in the app? Are you tapping on new printer and you get an error?

When I try to add a new printer, I get the above in my log.

It doesn’t seem like it is creating a child device.

Are you on Android? Judging from comments I have seen in other Smart Apps, I think I might have to modify a variable type to work around a bug in the Android app. Let me know and I can probably update it tomorrow night.

Actually I seem to be having the same issue myself now, I’ll let you know when I have an update.

Try getting the latest update, I added some additional logging.

I will update but as the kids are going to be out of school for a long while I converted my octoprint into a retropie today so they kids could play some classic games.

I noticed one thing, the percent displays go out like 10 digits after the decimal

Thanks for the feedback. I added code to explicitly format the percentage with 0 decimal places. Update from my repo and it should be fixed. :slight_smile:

Thank you for the hard work on this!

I wonder – do you think that auto off can handle logic that watches for when the nozzle goes from 200 to say 50 after a print is complete and then shuts off? I’ve heard that shut down immediately at high temps can cause some issues with the filament in the head cooling too slowly and then putting too much pressure backwards as it expands? I’ve not experienced this but I’m thinking more preventative.

@Daniel_Carter I just want to say thank you, so thank you! :wink:

Sure that sounds like a good idea. I hadn’t heard it was bad, but I did kind of suspect it might not be good to turn it off right away, so I included a 30 second delay, but I can try to change that to be driven by temperature.

@Daniel_Carter I’ve been using this successfully for a few days now. Is there a way to have the device configured as the Power switch also come on automatically when a file is sent to Print from OctoPrint?

Thank you! I’ve been playing with my Ender3 past couple months and set up OctoPrint/OctoPi last night.
To support showing more info in ActionTiles, could you add more DH capabilities like TemperatureMeasurement (Tool &/or Bed), MotionSensor (active when printing), RelativeHumidity (print job % complete), etc… ?

1 Like

Thank you for developing this - this is awesome and just what I was looking for!

Question though - I have two printers. I was able to successfully add 1 printer, but now when I try to add the second printer I’m filling out the name, IP address, and API code and I’m getting the error to fill in all required fields even though I have everything filled out.

As a work around, I logged into the Developer portal and was able to add a new device using the Octoprint device handler, then edited the preferences to include the IP address and API code. It’s updating perfectly and reflects the status of the printer, but when I go back to the Octoprint Manager smartApp I’m not seeing the 2nd printer listed.

Secondly, I did go back to the 1st printer which does show up in Octoprint manager and added a virtual switch to the power on/off section. When the printer stops printing, I’m not seeing the virtual switch being commanded off. Am I misunderstanding that functionality?

Ultimately, what I really want to accomplish is have the ability to make my Alexa devices announce when my printer is done printing. I believe having this Octoprint Device Manager is 1/2 of the step - the next step is to use Echo Speaks or some other add-in to make the announcement.

I was playing around with OctoPrint REST API and WebCoRE over the weekend at got it working. I didn’t think of having Alexa announce finished, great idea!