Have you connected a backup power supply to your HA Raspberry Pi?

Given the reliance on Home Assistant, it seems to make sense to protect it against a sudden power failure and the potential of corruption the SD card.

I wonder if there is any recommendation for a solid UPS for your dedicated HA computer? What are you using?

1 Like

I am using a cyberpower UPS connected to my Synology and utilizing the NUT sensor to trigger a few automation based on power loss and power restore.

a UPS isn’t cheap but is worth it when the power goes out. I have all my networking gear plugged into mine and its really nice when there is even a tiny blip in the power that I don’t have to resync everything.

You wouldn’t need a very big one for a Pi and a router/switch/modem. Keep an eye out for holiday deals or amazon prime day deals. I picked up a larger one for about half its normal retail by just watching the prices for a bit.

As @rabittn said, you setup a nut server and monitor it that way with the Pi. Don’t pay extra for a ‘smart’ network connected one. One with a USB output should be fine.

The wife really enjoyed being able to watch her netflix show during the last power outage.

1 Like

I like the “keep the wife happy” touch :wink:

E.

googling ‘raspberry pi ups’ will reveal plenty of options.

Yes, but I’d like to hear about the recommendations of the HA users. Plus, many of these links are sort of special homebrew projects and I was more looking for a reliable solution. Plus, with the Raspberry Pi consuming only 4 Watts, I don’t want to have a UPS that consumes 100W for standby
 :slight_smile:

I agree that real life recommendations are worth 1000 web adverts!

I think the first thing with UPS is to define what you want. Do you just want something that will keep your pi going for enough time to shut down without file corruption? Or do you want to keep it running to control your home until power comes up (and don’t forget whatever it is controlling is probably power dependent too). Also you need to work out what period your power is likely to be out. You could plan for a tree down on the lines - power company will probably fix it within 3 hours. But if you have an earthquake or flood or hurricane, you might be waiting a week, a month, 6 months - been there done that.

Good point, I should have specified that!

Do you just want something that will keep your pi going for enough time to shut down without file corruption?

Power outages are rare where I live. Most often it’s a fuse blowing/or being turned off because of some repair works in the house. So what I would need is the HA RaspberryPi to survive about one hour and if it is longer than that, ideally a safe shutdown trigger.

The problem I had trying to use one of the RPi UPS boards was that they require software to run on the Pi. Not an issue if you are running Raspbian but no good for things like HassIO.

Just use a USB powerbank (the ones used to recharge phones etc) connected to the Pi, then always on charge at the same time. Then you can have an automation to shut down the Pi on power loss if you want. A cheap and non-invasive way of detecting power loss using a plug-in wifi controlled power socket (compatible with HA of course) and leave that ‘on’, having the automation trigger based on that device falling off the network. If you have other things like wifi globes that never get turned off at the switch you could use one of those as the trigger.

3 Likes

Thanks Dave, that looks a good idea. So I would just plug in the RPi in the USB powerbank and continually charge that external battery?

A cheap and non-invasive way of detecting power loss using a plug-in wifi controlled power socket (compatible with HA of course) and leave that ‘on’, having the automation trigger based on that device falling off the network.

Any helpful link you could share here? So basically, then the wifi connection is down, a shutdown sequence would be initiated?

That’s right, just monitor a device (or preferably a group of many, using an ‘and’ condition) as being available. You can use the ping_sensor for that. If a bunch of devices have dropped from the network there is a good chance that the power is out (or your router has shat itself).

For example, I use Yeelight globes in my house and have then switched on permanently, turning them on and off via HA (using ZigBee switches) only, so they always have power to them and are therefore always online. I could (I don’t yet have this set up) have an automation to trigger a Pi shutdown if all the Yeelights were offline at the same time, being a fairly good indication that there is no power
 Of the router is having a problem. You could mitigate the router issue by having the automation only run the Pi shutdown after a particular duration just short of the powerbank running dead and hope that either a) the power comes back on in time, or b) the router sorts itself out and the devices are seen on the network again.

If you are handy with making up a modified USB cable and some circuitry you could actually splice into the USB cable that charges the powerbank, drop the voltage down to 3.3v and run it into the GPIO of the RPi to provide a charging/not charging signal and use that for your automation

Ah, I guess that would be a bit too sophisticated for my modest experience
 :slight_smile:

I am using a couple of products together for this. My system is mainly ip cameras which use POE, and PIR sensors running security system on the pi.

I used one of these for the battery backed power “CCTV 12V 8A 9ch Switching Power Supply with Backup”

Together with “LCD Display DC Buck Step-down Voltage Converter Regulator 5v-23v” configured for 5.2 volt (allowing for voltage drop with thin power cables - I cut down a thin phone power cable):

This runs the pi3. Then, outside of the scope of the question but I added a “DC 12V to 48V 4A 192W Step-up” module to get 48v for POE

And connected that in to a POE smart switch. This battery backs the cameras too. Several VLANs and a pfsense router allow me to isolate IoT devices and cameras, and the TV, (all I consider untrusted) and only allow the TV out to the internet for streaming content and firmware updates. My trusted network PCs can connect in to the other vlans to use those devices, but not the other way around.

Of course you could just run a normal mains voltage UPS to the pi but I had a lot of fun building this and I think it doesnt hurt to consider security at the same time if the HA components tie in to your security system.

Could you just use a USB power bank?

mains power > usb power bank > rasp pi

Usb power bank will keep charing when connected and power during outage.

Would assume you need a smart battery that cuts off charge when full and directs power straight to the ports (avoiding charge > usage > charge > usage 24/7)

The question regarding powerbank is what power you would need to reliably supply the Raspberry Pi 3+?

At least 2.5A

The difficulty seems to be that the manufacturers don’t advertise what power level the battery can supply, only the storage capacity. Tried a 12000mAh Anker powerbank today, that didn’t work. I did also read that some powerbanks don’t work with simultaneous charging and releasing. If anyone has identified a good powerbank that works with a Raspberry 3B+
 make yourself known! :cowboy_hat_face:

This may not be your answer, but a little while back, I had originally bought one of these

https://www.amazon.com/APC-Back-UPS-Connect-BGE90M-Charging/dp/B00NTQYUA8/ref=sr_1_12?ie=UTF8&qid=1540579437&sr=8-12&keywords=apc+battery+backup+%26+surge+protector

Thinking that I could use the USB ports to supply power to the Raspberry Pi.
Never really got to test it as I moved to an Intel NUC and would think that it is really underpowered for the NUC. I will most likely use it to backup my modem and router.

Also not sure why they are so expensive now, I think I paid like $45 about 6 months back.
But if this release power as it charges, this would be a nice solution.
If you could find one at a reasonable price, you could use the power plugs instead of the USB port . I have no idea what the power consumption is though.

For the guys talking about usb power bank as ups I think you need one that supports pass-through.