New problem--power failures

Ok, I had the printer on a relay and was using psu control & psu control Rpio. Well, I got a tp link smart plug and decide that it would be less connected wiring, so removed the relay setup and psu control rgpio and replaced it with psu control tp-link. Works great! one problem, when the ups loses AC power and tells the Pi to shutdown, the tp-link is still powered (which means so is the printer. Is there a bash cmd we could use to tell the tp-link to shut off (Can be issued from the apcupsd on onbattery)? Or a way for it to know the pi is shutting down and should power off also? Don't want to go back to the relay, although when the pi shut down, so did the relay.

Install a package called NUT on the pi. (Network UPS Tools)
There is a plugin for UPS monitoring for octoprint that uses NUT and you can set up actions to perform etc.

I have apcupsd running, it monitors the UPS. I just need a bash command to tell the tp-link plug to shut off. Apcupsd will shut down the pi on power loss by my criteria, but it needs to shut the printer by shutting off the tp link.

1 Like

The above link will get what you need done though I'd definitely recommend NUT over apcupsd. Plus you get to see the status in OctoPrint.

1 Like

Kantlivelong: Ok removed apcupsd and installed Nut. Installed the UPS plugin and activated CLI. How exactly, would I use this to tell the pi to shutdown the psucontrol. (old guy here, brain gets lost sometimes).

Provided cutting power won't cut power to your Pi you can use the pause feature in UPS then setup the pause script to send an M81 which will shut off power provided you have Enable switching with G-Code commands on in PSUControl. No need for the CLI stuff at that point.

I must not be clear. I don't want to just shut off the printer, I want the tp link smart plug to shut off. (Printer, lights, etc). Can the ups plugin tell psu-control to shutdown?

The UPS plugin won't directly do that. But as mentioned above you can setup a config to make it happen.

Found this: linuxscripts/tp-link-hs100-smartplug at master · ggeorgovassilis/linuxscripts · GitHub and modified it into a simple script. Removed nut and reinstall apcupsd (What I am used to since I have 4 pi's monitoring 4 ups) and put the script in the onbattery script prior to shutdown the tp-link before shutting down the pi.

Thank you