Autodetect printer on power on from running octoprint

Hello all,

I came across several post related to this, but they didn't quite solve my problem.
My usecase is that I have octoprint running on a raspberry pi 2B, which is running continuously.It is connected via USB to my prusa i3 mk3. I would like to just flip the power switch on my printer, and then be able to send jobs directly from PrusaSlicer to octoprint, which in turn sends them to my printer. All without having to go through the octoprint web interface.
But for this I need to find a way to have octoprint automatically connect to the printer.

I found 2 methods when googling:

  1. the PortLister plugin
  2. a udev rule and script.

Both of them don't work here. I think the problem is that both Portlister and udev wait for a usb device open event. But I noticed the prusa usb device stays visible when I power down the printer. Maybe the connection electronics are powered from the USB port of the raspberry pi. but an lsusb keeps showing the device id. And I tested that when I unplug the USB cable and reinsert it, the autodetection works like a charm.

Has anyone found a trick to doing this?
Is there a way to monitor if the port is live from the commandline? Because then I can integrate it in a script. I already have the script part to make octoprint connect to the printer.

Or is it possible to have octoprint continuously poll the port? It sends regular M105 commands when it is connected and detects the printer disapearing by the unanswered commands. If it would regularly keep polling, it would also notice the printer is back and could connect to it.

Any thoughts, advice and of course solutions are welcome!