Yes, several ways.
I have Ring Alarm Extender v2 devices that not only are Z-Wave Extenders, but also have internal battery backup and send “switch to battery” events to the hub when mains power goes out. Then, I have a voting rule that handles the fact that power can go up and down for a while before it finally goes down, maintaining a count of how many Ring Extenders are presently down. The voting handles the case where one or two Ring Extenders may have dead backup batteries (and thus not report power fail), and handles the case where a Ring Extender may be accidentally knocked out of the wall socket. Then, after some number (4 of 6, in my rule) of the Ring Extenders have been on battery backup for a few minutes (shorter than the UPS uptime, but long enough to handle temporary outages), the Rule shuts the hub down using a command to a simple driver by Dominick Meglio (@dman2306):
Here is the power fail voting Rule and its local variable, etc:
Power Fail Rules
There are also six pairs of similar Rules, one for each Ring Extender. Here is one pair, for the first Ring Extender:
And here are the Hub Variables (f/k/a/ Global Variables) that keep track of the state of the Ring Extenders for use by the voting rule:
It’s also necessary to have the following Actions in your systemStart rule to handle the fact that any “switch to mains” power event from the Ring Extenders is lost while the hub it powered down, etc:
There is a bit of subtlety in the design of the voting rule and its supporting “Ring x to battery/mains” rules, such that it handles concurrent triggering/execution of the various rules as the power flaps up and down.
Larry Kahn (@kahn-hubitat) has also done a nice job on code that receives power and battery status from an APC UPS network card. You might check that out.