Help with auto shutdown of RPi400

Am just getting into the RPi world with a RPi400 which I would like to use to host Echo Speaks v4 (due to the loss of free Heroku this November as is widely known). I have absolutely no experience with the RPi and absolutely no knowledge of NodeRed or Nodejs.

Given that hard shutdowns of computers are bad, I have set up my HE to perform a soft shutdown before my UPS runs out of juice. I would like to do the same for my RPi which I plan to use to continue to enable Echo Speaks. Does anyone have a simple, easy to follow method to do this? I understand that the RPi400 (I am expecting delivery sometime in the next two weeks) has a power button on the built-in keyboard. I suppose if worst came to worst, a could set up a physical bot to press the button before the UPS ran out, but this seems to be quite a Rube Goldberg arrangement and I would like to do this with a software only solution. Any help is greatly appreciated!

How is your HE monitoring the UPS? You should be able to put NUT or acupsd on the RPi which has settings to automate the shutdown. I have two mini PC servers setup that way, one goes off after 5 mins and the other hold on until the end since it runs the adguard DNS server.

1 Like

It really isn’t. Power outage is monitored through Ring Extender and HE shutdown occurs prior to UPS running out just based on time/previous experience.

Again, have no experience or current knowledge of RPi so will have to learn more about how to get NUT or apcupsd on the RPi, although may be a moot point since I am not using a apcuspd capable APC USP. May look into a CyberPower ST625U since it has 2 USB 2.0 charging ports that are powered when mains go off and might be controllable by NUT. Does anyone know if these ports are powerful enough to run a RPi reliably? I understand that one of the requirements of RPi reliability is a good solid power supply. Also, how to do this if I decide to go with a LiOn UPS outputing 5.0v? Lots to learn on my part. Thanks for any help.

The two options @jtp10181 mentioned are for integrating the UPS directly into HE. Does your UPS have a USB connector or network port for monitoring?

Aside from that, the best idea I can think of would be to host a webserver on the RPi that will run a shutdown script when called. Then you could do an HTTP GET from RM to trigger the script.

In theory, you could use the GPIO pins on the RPi to hook into a relay that you could control with HE like any other on/off device. There's plenty of guides about setting up two of the GPIO to use as a power switch. Replace the power switch part with the relay and you're cooking with gas.

I think that this may be the way to go, unless I get a UPS with a USB connector for monitoring (which mine do not currently). Thanks for your input. It is much appreciated!

Not necessarily, you can use either on a windows or linux server to monitor and shut down (or do whatever you want). I have mine connected via USB monitoring port to a windows machine and have acupsd running on two windows machines, NUT running a VM and then use the NUT driver on HE to keep tabs on it. I was just assuming they have the UPS connected to something via network or USB, forgot about the other options.

Knowing now you have no way to truly monitor the UPS, then yes the suggestions by @FriedCheese2006 would be the way to go.

Also, FYI, the charging ports on a UPS are not the same as monitoring ports. You do not "control" the UPS via acupsd/NUT, you monitor it. That being said the model you listed does appear to have a monitoring port on it. You should be able to connect that to a USB port on the RPi and then run one of the monitoring servers to get updates from it and act accordingly.

image

1 Like

Fair point. I immediately jumped to how I'm using it. I just have apcupsd setup on a Windows machine and use EventGhost to push the UPS data into HE. Didn't even think about the option of cutting out the middleman and just using Windows to script out my shutdowns.

If you have a telnet port open on the Pi, you may be able to write a small driver/app to connect and issue the shutdown command.

1 Like

...... :slight_smile:

Well I do have a test driver at https://raw.githubusercontent.com/thebearmay/hubitat/main/telnet.groovy that could serve as a starting point :sunglasses:

4 Likes

Of course you do.... :wink:

3 Likes

Thank you very much for the clarification. Will have to look into getting a unit with the monitoring port. One question I have with regards to the USB charging port is the efficiency in the conversion from AC to DC. I know that plugging a wall wart into a typical AC UPS does not give me nearly the run time as plugging the device DC power cord directly into a UPS with a LiOn battery powered UPS pack with the appropriate output voltage (DC) and amperage (due to transformer inefficiencies).

Do the USB charging ports that are built into the UPS suffer from the same inefficiencies (or since the AC is already stored as DC in the SLA battery, and does not have to be reconverted to AC to power a wall wart, is it much more efficient)? Bottom line is that if I were to use the USB charging ports to power my RPi and my HE, would I get more run time after power failure than if I used the supplied wall warts plugged into two of the AC outlets? The reason for asking is that one of the motivating factors for going with a UPS such as some of the units being developed by one of our community members is 1) smaller package size and 2) longer run time. However, that comes with the obvious risks of 1) non-UL or ETL certification and 2) the inherent potential fire hazards of LiOn rechargeable batteries compared to SLA batteries.

Thank you again @jtp10181 for your input as you seem to have a pretty good handle on these things!

Unbelievable! Or should I say, “fully expected”, LOL! @thebearmay is truly amazing! I should have known.

2 Likes

You're learning.... :wink:

2 Likes

It would be good for the rpi to monitor the ups via 'nut'. Expecting a new to linux person to configure nut is not reasonable. I must have installed nut 5 times in the last year and I still hate it.

As a noob with RPi and Linux, much less NUT, I found a pretty detailed step-by-step guide to getting NUT loaded and operational on a RPi here:

Have not tried this yet but for those with experience, does this seem like reasonable instructions on how to get this running?

That article is 6 years out of date. That is o.l.d. Somethings should work if you've done all the previous steps. Things like their smtp mail configuration is unlikely to work and a deep hole if it doesn't. Outdated is one of the nut problems.

Thank you! That’s why I asked! I figured you guys would know best.

So, it turns out I had a number of APC Back-UPS750VA’s on hand that have the USB B ports on them for utilizing PowerChute, or NUT or APCUPSD. Supposedly, there are versions of each that work on Linux, so I am guessing (in my relative ignorance) that there should be a way to get them working with RasbianOS? (Due to my inexperience with the RPi platform and OS, I was advised to stick with RasbianOS as this is the most convenient OS to use for beginners).

However, I have not been able to find a recent set of instructions to get everything to work. I assume that I just need to get a USB-A to USB-B cable to connect the UPS data port with one of my RPi400 USBs after getting one of these programs to load on the RPi? (The trick being getting the programs to load and work on a RPi of course).

@ccoupe noted that the link I referenced was really O.L.D. and out of date. Does anyone have any straight-forward-to-follow current instructions on how to get one of these programs to trigger a safe soft shutdown of my RPi? I’ve got to believe that one of the brilliant community members here have done this successfully (you guys have never disappointed me yet!). If so, how did you do it and which program did you use? Thanks again in advance for any help on this!

If you a familiar (enough) with the command line and the concepts of Linux processes and drivers then the instructions can work - it's just you might need something more, maybe. On the other hand it doesn't hurt anything but pride if you want to try. Nut is want you want. Just hook that weird USB cable up to a port on the Pi (or a hub for the pi - I always run out of ports).

Edit: Coincidentally, I have to install nut soon on larger Linux system using these instructions.

Edit-2: Why do they never include sudo and assume everyone knows that they need to be root?

1 Like