Detect power outage and notify

I want to get a notification when there’s a power outage at home. Home Assistant and the ISP modem are on a UPS, but it’s a dumb UPS. There’s no software interaction with it in any way.

I do have a camera that is not on a UPS though, so I though I would have Home Assistant detect when the camera is offline and notify me.

How can I configure Home Assistant to detect if the camera is down, and sent me a notification that there’s a power outage and then notify me again when power has been restored?

Thanks

No USB or anything on the ups?

Putting a power monitor on the source of the ups will give you a meter reading.

ok, any suggestions on power monitors that are cheap, and compatible with Home Assistant?

Αρίστο,
a simple workaround is to use an esp8266 board with ESPhome firmware and one GPIO sensor connected to a relay that is powered by mains (or UPS output)
…assuming that the board is powered by a small battery or super capacitor to keep the ESP alive for couple of minutes
a simple solution for less than 10€

I have a sonoff pow flashed with tasmota connected to the power in to my UPS. Template sensors detect if the power values haven’t been updated for 10mins then I get a notification.

Thanks for your replies. I decided I want to use existing equipment and try to simplify this as much as possible. So, currently I am monitoring 3 hotspots and an appletv

binary_sensor:
 - platform: ping
   name: Apple TV
   host: 192.168.1.17
   count: 2
   scan_interval: 30
 - platform: ping
   name: Hotspot Kitchen
   host: 192.168.1.3
   count: 2
   scan_interval: 30
 - platform: ping
   name: Hotspot Bedroom
   host: 192.168.1.4
   count: 2
   scan_interval: 30
 - platform: ping
   name: Hotspot Livingroom
   host: 192.168.1.2
   count: 2
   scan_interval: 30

I want to send an email if they are all down. (HA and modem are on UPS)

I tried it like this, but I get yaml parsing errors in HA

- condition:
 - condition: state
   entity_id: 'binary_sensor.apple_tv'
   state: 'off'
 - condition: state
   entity_id: 'binary_sensor.hotspot_kitchen'
   state: 'off'
 - condition: state
   entity_id: 'binary_sensor.hotspot_bedroom'
   state: 'off'
 - condition: state
   entity_id: 'binary_sensor.hotspot_livingroom'
   state: 'off'
 action:
  service: notify.email_smtp
  data:
   title: Home Assistant
   message: Monitored Devices OFF

help?

2 Likes

Use a ping sensor. When some device that relies on mains is down, assume the power is off. (optionally when hasn’t responded for some minutes.)

The trigger should be a template based on the state of the sensors not the condition I think

I know its late. I am just leaving it here, as I visited this thread a few days back, with little luck for implementing a power outage sensor.

It is better with a high end Inverter. Agreed. For those who do not have one, it is still possible to monitor and recognise a power outage. Using Fully Kiosk browser it is possible to monitor the “plugged” attribute from the REST api calls, and strip these values to a template sensor. You can see more detail here:

This list of attributes were then updated to include additional variables.
There is a post here: Fully Kiosk Rest API Integration in Home Assistant.

It is very simple to implement, especially since tablets have battery power, and it would detect when a power outage happens by updating the sensor data with a “false”. You can trigger an automation with this value on state change, or send a shutdown command to shutdown your remote pc.

You can also use the ping command to see if “something” responds.
Here I use it on my TV but I will replace it with a different method later because it’s slow to respond.

It takes an average of the pings and it takes some time for it to understand that the TV is off, with time I mean like 5-10 seconds.
I know a lot of you will think it’s not a big deal, but o want it quicker.

Just a thought on how else to do it.

I believe this is usually the case with sensors in HA. How about using Fully Kiosk, or something similar, and monitor state changes via MQTT. I can see that state changes can be reported much quicker as per the configuration in place. I can see quick changes when power goes off on MQTT Explorer, but I am very new to this, and don’t understand how to integrate MQTT responses yet. May be MQTT is a better option?

Why not plug an esphome device into a charger. Put it somewhere it isn’t going to be unplugged accidentally (or by a teenager who has lost their charger). Then ha will know instantly when power goes down.

I found a cheap solution and it may help someone someday.

Used
1- Sonoff Basic (with Tasmota firmware )
2- 220v/120v Relay (will leave link but any 220/120v AC relay will work) (You need to know how relay works :slight_smile: but i will try to explain )

Relay function is to take input AC signal (220v or 120v), and it makes two output totally separate from input voltage outputs called NO (normaly open) or NC (Normally closed )signal (Think of it as a wire either connected or disconnected by default “switch” so if 220v is present then wire is connected if not then wire is disconnected).

At our example let assume using the 2 pins for NO (Normally Open) at relay will be connected at ground and at Rx pin for example at sonoff then from here you can play with it as a normal switch and configure sonoff tasmota as switch.

Of course Sonoff need to be on UPS and Wire input to relay need to be on non-ups outlet.

Relay link : https://www.aliexpress.com/item/32650628066.html?spm=a2g0o.productlist.0.0.47652910S60tao&algo_pvid=995c7d06-851e-40fa-b3e0-6abe1781c513&algo_expid=995c7d06-851e-40fa-b3e0-6abe1781c513-0&btsid=0ab6fab215907971532548305e73c2&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

The Ring z-wave range extender has a battery backup and can be a simple way to detect power outages when it switches to battery mode.

1 Like

This is a good idea as I am also looking for same.
Tasmota device makes many entities “unavailable” when it is switched off. I feel that can also be used by plugging that device to that plug.

Not quite sure how accurate that will be in the end because a “unavailable” state can have various reasons which can range from something like no HA/MQTT/WIFI connection (while the load being still on) down to a burning device :fire:

Apologies for reviving an old post, but for anyone that comes across this thread looking for a possible solution, I came up with one after being rudely awakened by some Zigbee lights that have a start-up state set to on…

If you use Zigbee, and have a switch that is acting as a repeater that doesn’t have to be on a UPS, or really shouldn’t ever change its power state, set the start-up state to power on/off. Then set up an automation to trigger on the state change, with a final action as reverting the power state.

It doesn’t have the cool factor of some other solutions, but it was a simple option without buying anything additional.