I wholeheartedly second using Ring Alarm Extrnder v2 to detect power fails. It has a built-in battery so it works during power fails (assuming your hub is on a UPS). It’s straightforward to write a rule that receives the switch to battery event and shuts the hub down a reasonable time later before the hub’s UPS dies. If you want to see my rules, just ask.
Cautions:
-
It needs to have a direct (unrouted) connection to your hub. Otherwise, if it routes through another repeater that does not have battery backup, the “switch to battery” event will never reach the hub.
-
When your house comes back up, the Ring will send a switch to mains event before the hub has rebooted, so that event will be lost. So, you need a Refresh action in your systemStart rule so the Ring Extender’s state becomes accurate.
-
The built-in driver for the Ring Extender has a bug, in that the Refresh custom action (and the Refresh button on the device’s page) doesn’t work. I’ve pointed this out twice during the past year to Bryan Copeland but, as of 2.3.0.124, it’s still broken.
Denny Page has written a user driver for the Ring Extender v2, and Refresh works in his driver. I have switched to it.