Plugin Idea – Retry printer connection after API calls

I'm using Octoprint in a unique fashion, I suppose. I turn my printer on/off with a smart switch so that it's not always running. When I want to use Octoprint, regardless of how long after I've turned on the printer or whether an app (i.e. Cura) checks whether the printer is connected, Octoprint is always disconnected and requires I hit the 'Connect' button.

It'd be nice to be able to configure the retry logic to be a bit more forgiving towards printers that are powered off before they need to be used. I think a 5-10m retry would handle this case pretty well without overcomplicating things.

A smarter way to do it could be to listen for specific edges where a user is likely desiring a retry. If I load the web interface after it's been idle for a while, or if I launch Cura which uses the API to check the printer status, these are clear indicators that a retry couldn't hurt. In the cases that I'm doing that, the printer is on and would succeed, but I have to go manually hit 'Connect' before anything can proceed.

I'm not sure how to make a plugin, or if there's a plugin that already does something like this, but figured the folks here could comment on the idea. Thanks!

Edit: Digging around it looks like I can disable the max consecutive timeout while idle and accomplish the simpler solution, though an intention-based approach could still be better.

You might be interested in the PortLister plugin:

It has an auto-connect feature when it notices the port is available.

Thanks, I'll see if that does it! I have the port being forwarded with Docker so I'm not sure it'll come and go in a way that can detect.

Edit: Unfortunately this won't work for me via Docker.

Which smart switch? There are several plugins (some are mine) that can control those already and I know most of mine have that connection logic built in and auto power on when I upload files with the option to autostart the print.

I'm using a HomeKit one, maybe can find one that's also supported via the plugin. Can you share one you've used before?

There is a homebridge plugin for Octoprint, which would kind of do what I want (I could "turn it on" at the same as the printer in Home App) but the plugin doesn't force a connection, just controls a print.

I've used TPLink Kasa based ones as well as wemo ones and anything that can be flashed with Tasmota firmware (several options there).

Thanks I have a Wemo switch I can swap out for this purpose, seems this will solve my problem as there's a feature to connect to the printer once the switch is turned on (even outside of Octoprint). A general solution could still be nice, but this will do for now!

yeah, portlister will typically work in that scenario, as long as you have the options saved to automatically connect to the printer on start up.

I had to come back and say how awesome this Wemo plugin is! It has features I didn't even know I wanted, like powering on the printer when I upload a new file, and off when idle after a print. Super cool, thanks for sharing!

Sure, glad you appreciate it.

1 Like