Safe way to power down Hubitat after power failure

I've read numerous posts concerning this topic but most refer to the use of a Rpi etc. I'm a novice compared to most in the community and just looking for a simple way to power down the hub to prevent damage to my database. I do have a battery backup that should power the hub for a few hours but recently we've lost power for longer periods of time and the reason for my concern. I'm really looking for a means, first , to know if a power outage has occured and second either write a rule to safely power down the hub or allow me remotely to power the hub down using possibly a dashboard tile, etc.

I noticed Cobra has an app " power off shutdown" which looks exactly what I'm looking for but requires a contact switch being rewired and connected to power block which I'm unfamiliar in doing. Previously a product was made to do just that but doesnt seem to be available. Any suggestions would be greatly appreciated.

I remember a post on this also. - Following

Rules are not my strong suit so this could be way off. However it is raining, and I am stuck inside so here ya go....

Plug a smart plug into a dumb outlet. Connect your battery backup to the smart plug. Then connect your hub to the battery backup. Create a rule to monitor that plug. If it went off, try and turn it back on, if it won't turn on (power outage?), wait, try again, after X minutes send the shut down command to the hub.

There are some obvious flaws in this process/rule, but it's a start.

1 Like

First, build yourself a device that detects when power is off, i.e. a Power Monitor.

Then write a rule like this:


Power monitor *changed*


IF (Power Monitor open)  THEN
    Send POST to http://your_hubitat_ip:8080)hub/shutdown --> delayed 1:00:00 (cancelable)
    Cancel delayed actions

For this to work, you must have disabled hub login. Set the delay to the appropriate length for your battery backup.


If the plug is unpowered (loss of power), it will not send a status update of being "off" to the HE. But it is relatively simple to make a battery powered power monitor using a contact sensor.

These are easy to build and I have it monitoring my fridgerator circuit - one with 3 fridges on it.

Another option is @iharyadi's environmental sensor. I purchased several of these because I also wanted humidity, temp, etc too and it is capable to alert you of a power outage since it has a backup battery option. As you may have seen in the post @aaiyar mentioned above I originally built the power sensor for my sump pump but I have since switched it out for Iman's sensor so I can monitor humidity in the crawl space too.


Is it possible to use TechMedX idea of using a smartplug connected to the battery backup and Hubitat. Then use your rule to sense when smartplug turned off (do to power failure) and then send Post to shutdown hub after a designated delay and CANCEL shutdown if power resumes?

No. When the smart plug is no longer powered (because you've lost electric supply), it will not send status updates to Hubitat. So Hubitat will never know that it is "off".

Edit - hence the need to build the kind of device that @ritchierich designed. They're actually really easy to build, and cost less than $30.

If you had a device that "reported activity" regularly, could you base a rule on the lack of "reporting" activity?

Or what about have something like an Aeotec Multi sensor and monitor it's power state. If it switched from USB to battery trigger the rule? does not work

By far the contact sensor things is cool, and much more bullet proof. I'm just looking out for the KISS solution.

I build something like this. This sensor already include power monitoring. You can just not use the smoke detector connection and put it inside a box and wire it to your AC power that is in the same line as your hub.

When the power is out, the sensor will send out notifications.


Thanks to all! I just have to commit in TRYING to build a sensor that will send out notifications. Much appreciate everyone's suggestions.


This would be a great feature for the "HE Pro" - rechargeable battery backup with built in automatic shutdown. Add true POE support I'd pay top dollar. :smiley:


Here's a list of parts that you will need to build one:

  1. USB power supply
  2. USB power cord
  3. 5VDC relay
  4. A zigbee/z-wave contact sensor with external contacts (I use a GoControl WADWAZ-1 - $7 on eBay).
  5. A project box to put the relay and contact sensor in

Takes about 15 minutes to build. Here's what my finished sensor looks like:


Well with all the info and links you graciously provided how can I not give it a try lolo. Big thank you aaiyar ! One question- where are the wires connected in the sensor. I had a relay from my last konnected install, so I'm good with that part!


Looks like you got a steal!

Found 1 left used $15 on ebay

or this monoprice one should work to right @aaiyar ? It does have external contact

1 Like

Yup. That'll work. There's also people that have modified cheaper zigbee sensors (like Xiaomi) by soldering wires across the reed switch.

I just replaced my two GoControl sensors if anyone is looking for one.