Octoprint Server device handler

Edit: Fiddling around with it more - I’m able to get Echo Speaks to work when the OctoPrint server itself is switched on and off. What I’m not able to do is get a trigger when the OctoPrint device goes “Idle” or is no longer printing.

I think that’s what the Power Switch setting is for in the OctoPrint Device Manager server settings? But I’m not seeing my virtual switch turning on and off with the print jobs so I’m not really sure how that’s meant to work.

Wahoo! @kevin thank you for the indirect point in the right direction. I decided to play around utilizing webCoRE and was able to get this to work.

My piston is very simple -

if my printer’s displayStatus is ‘idle’
then with (amazon Echo devices) do Speak text “Your printer is done printing.” (only while Home);
end with;
end if;
end execute;

Awesome app! This saves so much work vs, wiring a switch to the R Pi and controlling that way. The only issue is the timeout is too quick. I’d like my printer to stay on for 10 minutes or so, so that the heaters can cool down with fans.
How do we change the 30 second timeout? Could a variable be added to do that? I’m sure I could figure out a WebCORE piston to achieve it, but that’s another work-around…
edit: I belive I’ve found the solution to this, in the device handler:

if (success && device.currentValue(‘autoOff’) == “true”)
log.debug “Shutting down in 5 minutes
runIn(300, “autoOff”)

Hi Brian_Meissen, sorry for the delay in my response.

You do have to add the printer through the SmartApp to have it show up in there, that’s why your workaround device didn’t appear in the app. As far as your issue with required fields, I remember an issue coming up at one point where the Android app was requiring that at least three characters be entered in a required field. If you’re still having that issue, try putting 3 chars in the Port field just to see if that’s the issue. If it is then I will remove that as a required field.

Per your issue with autooff, if you’re sill having issues, could you view the Live Logging in the IDE as a print is finishing up, and copy all the logs up until a minute or two after it finishes?

If you get the latest from my repo, I have made the following updates:

  • Added option to shut off based on a temp threshhold (thanks @jskinnerjr for the suggestion.) This is set in the device settings.
  • Added setting for auto off timeout (@Essavant you found the correct code, but now you can use this setting instead of modifying the code.)
  • Set Port as a non-required field due to a possible bug (@Brian_Meissen this may solve your issue)

You should also just go into your device settings and hit save to save default values for the new settings (or you may want to modify them.)

@kevin and @GoodyGizmos, I will look into your suggestions.

Thanks all!


Just had to drop a comment in here. Thanks Daniel my man! This is awesome!

Just a bit of advice to my fellow users. Watch out using the DeletewhenComplete plugin within Octoprint. That sucker will mess up this device handler by causing the code to get a ‘null’ for the file name and think the print failed.

Just started with 3d printing and recently set up octopi. Then my thought was hmm can it connect to Smartthings.
Thank you so much for this! Any chance of getting it to display more information in the new Smartthings app?

Awesome update! Thanks very much for writing such a useful app!

Can you add motion capability and tie that to Printing (ie, printing shows motion, printing finished motion stops). This way we can easily use it with IFTTT or for Alexa Routines to announce when a print has finished.

I have updated this with a few of your suggestions and some of my own. After updating both the smart app and the DTH with the latest code from my repo, make sure you open the SmartApp and just click save (this forces the app to subscribe to a new event, needed for push notifications) and open the device settings and hit save (to save default values for new settings.)

  • Added capabilities for use in other apps (Motion Sensor = print active; Temperature Management = hotend temp; Relative Humidity Measurement = print progress) (Thanks @Kevin & @Essavant for the suggestions)
  • Added option to send push notification when print is complete
  • Added option to bypass print failure check and another option to use autooff when print fails(since @luganator pointed out that some plugins may cause false failure reports)
  • Added tile to set dry run mode (printer runs without heating or extruding) - this has proved very useful in testing

That said, I have bad news, I am jumping ship and moving to Home Assistant, so I’m not sure if I’ll be updating this anymore. I saw recently that Samsung announced they will eventually do away with the Groovy IDE and also retire the v1 hub which I’m on. I doubt these will happen any time soon, but best to start preparing. Unfortunately that also means that this SmartApp/DTH will no longer work after the Groovy IDE is no more. There is a replacement of using web APIs but I’m not sure how many developers are going to go that way since it sounds more complicated, requiring either the devs or the end users to host their own apps.

But anyway, enjoy this while it lasts! :smiley:

1 Like

Have you considered Hubitat? It is very similar to ST but much better! I was an early adopter of Hubitat and found it easy to migrate from ST. I still follow these forums because it is so easy to port drivers and apps from ST to hubitat

Yea I was looking at that a while ago and the only reason I didn’t switch back then was because I had invested a lot of time in custom integrations with ST, and because I didn’t want to have to migrate all my stuff to a new hub. When I heard the news a few weeks ago, I thought I’d make the move, but Habitat has been sold out since then and I would bet it will be for quite a while. I heard about Home Assistant and decided to give it a try. It seems pretty cool so far, as long as you’re willing to put in a little time and research to get things working. Not sure about Habitat, but this has a MUCH nicer UI than ST, and it’s nice to have everything local.

@Daniel_Carter great job on this I noticed one issue on WebCORE and I needed some assistance. Whenever I attempt to use the PrintComplete I am unable to select the option “True” even though I select “True” on selecting “Save” it reverts back to “false” any assistance from you or anyone on this thread would be greatly appreciated.

Thank you

Hmm I’m not sure, this seems like a WebCore bug. I can say that I only fire the PrintComplete event when a print finishes though, so maybe you can just set the comparison type to “changes”? Or if that doesn’t work then maybe use the new motion attribute as the trigger?

I’ve tried to add the Github repository, but I’m getting an error “You don’t have access to karatecarter/Octoprint-Server”.
Is this device handler now defunct? or am I doing something wrong?

I am no longer using ST, but I think it should still work – I will check if there are any new github security settings or something.

Hi, does anyone have this working with the new smartthings app? thanks

Yes but functionality is limited compared to the classic.

I know this is an old thread, anyone able to get this to work with the new SmartThings app? I tried to launch classic but it just sits at a splash screen now.

Any help is greatly appreciated, would love to get this integrated in.