Camera Stream frozen and not loading

Where has this script to be placed and how does it gets executed?
Does it communicate with the PSU-control plugin?
(i don't have much experience with python scripting obviously)

This is a shell script and not a Python script, also the script I've posted is not functional as is. As I told you it lacks the command to trigger a GPIO pin from the command line, which should be written where I've placed #Command to trigger the GPIO pin to turn off the relay (lines starting with # are treated as comments).

The script should be placed inside the octoprint venv, and be owned by the pi user, and allowed to be executed (chmod +x script-name). This script does not really communicate with PSU-Control, the plugin would just invoke it to turn the relay on or off. I asked @kantlivelong, who wrote the plugin, how those scripts can be handled on the discord, and I'm waiting for his answer.

Well, after discussing this with @kantlivelong on the Discord, he gave me an idea, and I want to actually try something to figure out this situation before writing a script.

Here's what I'd like you to do: when you're not printing, and still can access the stream, could you use SSH to log into the pi, and run the following command: dmesg -w then trigger the relay (activating or deactivating the PSU), and then post the output of the dmesg -w command here. You can quit the command and return to the print by pressing ctrl+c on the keyboard. That would tell us if the webcam is somehow disconnected while triggering the gpio pin. If so, we could leverage a udev rule rather than have PSU-Control call a script.

PSU_on.log (33.4 KB)
PSU_off.log (33.4 KB)

Thanks you for your efforts!

Ok that's strange, but somehow the camera doesn't get disconnected during the PSU being switched on or off... I'll read a bit more on how GPIO pins can be triggered from a shell script, and I'll get back to you with, hopefully, a functional script then.

I was just realizing what I was doing didn't make a lot of sense.
I used

when the power supply was already on and the stream was working and then disabled the power supply and tried again. But shutting down the power supply actually never caused the problem, so...
PSU_on_after_off.log (20.8 KB)