How to use shell commands to make octoprint connect automatically to printer

Okay Hi, this is the first time for me on the forum but here goes. I use octoprint for my printer but am building an advanced enclosure.
In this enclosure are 2 Ender 3 Pro’s. I connected them both to the pi and am running them both on 1 pi with Chris Riley’s technique i found on YouTube.
That is all working great with 2 webcams and all. However, i have also connected the printer power cords to relays (and the lights as well) to control everything trough octoprint. I also connected multiple buttons in the inside of the enclosure to toggle the lights, and toggle the printer power and preheat gcode commands with the enclosure plugin. However, when I turn on the printer with the button I first need to go to the octoprint server to connect before I can use the preheat button.
With the enclosure plugin you can also use shell commands with the same ‘turn printer on’ button. However I am new to this and have no idea what command to use to connect the printer.

So in conclusion:
With the enclosure plugin you can use a shell command with the press of a button. I need this command to connect my printer to octoprint (because it disconnects ofcourse when you turn off the printer).
If anyone could help I would be very happy😇

If you have any other tips or suggestions for the project I am very interested!
(Or if you would like to see the result ofcourse!)

Kind regards
Friso

See the portlister plugin on plugins.octoprint.org. It will let you automatically connect once a serial port becomes available.

On a sidenote: just because there is a tutorial on YouTube doesn’t mean it is a good idea to run two printers and two webcams and lots of enclosure logic on one Raspberry Pi.

Thank you very much!! it worked for me!

I understand that it is a bit much for the pi, but right now it seems to work and the print quality is the same. Could there be any issues or dangers overloading the pi like this? I mean, if i see the print quality differ I will change it ofcourse, but could the pi overheat and cause serious damage? The pi is cooled outside the enclosure.

Thanks in advance! :smile:

Think of it this way: if you have two prints going on at the same time, and one of the OctoPrint instances causes your Raspberry Pi to crash, chances are you'll loose both prints. You have added a "single point of failure" to 2 printers.

NB: I'm not suggesting OctoPrint is likely to crash a raspberry pi, but there is a non-zero chance that something goes wrong.