Home Power Failure


#1

I am going to grab an APC UPS for my router and HASS raspberry pi, and I’d like to get a notification when power goes out. I could then check in on things and make sure lights are off (although hue is fixing this in an update), etc.

I was thinking of maybe plugging the UPS into a smart plug, and if the voltage/power/amps goes to 0, it could be a symptom of a power failure. Maybe adding some conditions that the plug voltage is 0, all hue lights are unavailable, etc and then trigger a power failure automation.

Any ideas?


#2

Look into a UPS that supports NUT and you can connect it to your pi directly via usb.

I do this and have sensors setup for power usage and outages. I also have notifications for outages.

You obviously need to maintain internet connectivity for it all to work.

See my repo for the UPS I use and all the config information.


#3

The voltage on the smart plug would not go to 0, the whole plug would become ‘unavailable’ - because the power just went out :wink:

I don’t know how quickly your device_tracker works, but mine for my WiFi-based smart plugs would only notice after 10 minutes.

I know there is a sensor for APC UPSs, but I never tried it.


#4

I have a handful of APC UPSes (and 1 CyberPower UPS). I have one connected to my HomeAssistant system with a USB cable and use apcupsd with the apcupsd component. Most of the APC UPSes will give you battery status (Online or On Battery), as well as the input voltage, load, battery %, and an estimate of remaining runtime. Some of the lower-end models won’t provide all of the data though (The UPS currently connected to my HA system doesn’t report input voltage for example, while the one on my workstation does).

Keep in mind though, you’ll only be able to notify yourself of power failures, and that’s assuming HA, your router, and your modem are all on battery backup. You won’t be able to write an automation that says “power failure -> turn off all lights” because the lights will all be unavailable. However, you could write an automation that says “if the UPS is on battery and switches back to utility power, turn these entities off”


#5

Cool, thanks for the help everyone! Some good tips to look into


#6

Like other’s have said, if you can get the UPS into HA that would be your best bet. I do something similar using the NUT component.

I just look for the input voltage to drop below 80 (figured that was a safe number) indicating that it lost power:

        ##########################################################
        ## UPS Power Loss Alert
        ##########################################################

- alias: Notification Text - UPS Power Loss Alert

  trigger:
    - platform: numeric_state
      entity_id: sensor.ups_input_voltage
      below: 80

  action:
    - service: notify.ios_aarons_iphone
      data:
        message: Power Outage Detected

You can check out more here


#7

What happens when the UPS battery runs out and you have to restart Home Assistant remotely?

I claim that you would to sequence the power up so that the router is ON a few minutes before the Home Assistant device is powered up.

See my related post here.


#8

How are you going to restart it remotely with no internet connection?

I don’t think there is a way to delay the startup of HA until the router is fully booted up. It seems like it should keep looking/trying until it does have a connection though.


#9

Once the power is restored in my house I could restart Home Assistant remotely provided that the power up reboot was successful. That is the issue. It appears that HassOS only checks once for a LAN connection. I have submitted a bug report here.