I couldn’t find a simple way to tell that the power has been cycled. There is a field in the hub data that is batteryInUse. You would need to track when this gets set to Yes and then back to No.
The first issue is that getting that value is a pain. The only way I found would be doing an html request and then parsing the results.
The second (and more critical) issue is that when the power goes off, the internet goes off and the smartApp would stop receiving events, since it is not processing locally. This mean you would never get the initial batterInUse flag. This can be overcome with a UPS, but I would need a second one as I have Fios and would need a UPS for the phone switch and the router, since they are in 2 different locations.
I would much rather use an indicator coming from the hub, but until both of the above issues can be addressed, @JDRoberts’s suggestion for a canary bulb really is a brilliant idea. Beside only costing a $15 bulb, it is capturing the exact event that I’m looking for, Smart bulbs turning on due to a power outage.
I’m glad I could help out, I’m sure you will find another project for your first SmartApp.
If you tackle the issue of determining the hub lost and regained power, please share you code, as that may give me enough incentive to get another UPS.