Trying to detect power outage

First off, I love this little device! It works so well and I love the insights I’m able to get. I have mine incorporated into Home Assistant and it’s wonderful!

I have been trying to figure out a way to use it to detect a power outage. I have a battery pack acting as a UPS and it works great. I set up Home Assistant to send an alert when my mains drop to zero. Well, I had a power outage recently and I never got alerted. I noticed looking at the history in Home Assistant that the power never dropped. I thought maybe I’d need to output the reference voltage and I could monitor that. I tested that too and still didn’t work. If I look at the voltage value in Home Assistant and pull the plug out, it never drops. It appears like the IotaWatt just stops updating.

Is this intended behavior? Is there some other way I can accomplish this?

Since you have HA…any chance you have zwave or zigbee networks? There are a couple devices that run on mains and/or battery and report to the hub (HA in your case) which power source. I utilize a Ring Range Extender that is a z-wave device for this purpose (and I know of some thermostats that can do the same). Since it has a battery it has power to send out the message after the power goes out and my hub is on a UPS so it can catch that message and act on it by sending out a notification or whatever else you want to do.

That said…My guess is if you have a mechanism to read the iotawatt’s data then seeing 0V on the VT would be a good indication that your power is out.

So is your wireless network and the other parts of your network all on UPS also ? i.e. how does the IOTAWATT communicate to HA if the wireless network is not there ?

Assuming you do have a valid path i would just query the IOTAWATT every 5 sec and ask it for the Voltage on your mains.

You could do this in HA or use the Node Red add on for HA.

Alternatively just run a ping of something from HA that is not covered by your UPS and that should be available all the time - if it is absent then a fair chance of mains failure


The original design did not contemplate collecting data during power outages, as there is no data to collect. Emphasis was placed on restarting quickly when power resumed. That’s one of the reasons for the battery real-time-clock, so it hits the ground running knowing the correct time without needing to get it from the internet. Routers and cable modems can take a relatively long time to start up after a power failure. IoTaWatt takes a couple of seconds.

Now things have gotten more complicated. Users are running their IoTaWatt with a UPS power supply, and there are generators and battery backup critical load panels to be measured.

Several months ago I made some changes to allow the unit to work with no AC reference active, or one of several AC references inactive. The changes are merged and in the master branch, but I have not cut a release since then. It was time to integrate a new ESP8266/arduino core, and there are breaking changes that needed to be addressed. There is also an issue with reduced heap. Because of the breaking changes, it will be a leap of faith to release this version and I am taking the time to burn it in before packaging and pushing out to the many thousands of installed units.

So look for zero voltage to work in the next release, but I can’t say when that will be. I’m shooting for September.

This is exactly what I was looking for! Looking forward to that release! Thanks!

I like that idea of something that can report it’s power source. That seems like a pretty good solution.

As for the reading of the IoTaWatt - the issue is that even though I am keeping the device powered, if the power goes out it just pauses it’s reporting at the last value. I thought about trying to track if a value hasn’t changed for some set interval, but that didn’t feel like a great solution.

That’s because it’s basic operation is regulated by the AC cycles, so that it can sample full cycles and do useful work. When the AC cycle isn’t there, it cannot measure anything. That is what was fixed. It now identifies the lack of AC and logs zeroes.

1 Like