Help modifying an app code

What you're expecting is that in the event of a power failure, your ZEN04 will report a voltage of zero. As @sburke781 explained, this will not work, because the ZEN04 will be unpowered during a power failure.

However, there are several alternative methods to let the hub know that there has been power failure, all of which make use of devices that are battery powered.

  1. You can make a Power Monitor - costs about $15-25 to put it together. This thread has a number of examples.
  2. You can use a Hubitat-paired thermostat like z-wave models from GoControl or Honeywell. These can be powered by both the HVAC transformer and batteries. When A/C power is lost, the thermostat will report it is no longer on "mains" power, or will report it is on "battery" power. These thermostats cost about $50-100.
  3. You can use a Ring z-wave range extender. These are plug-in devices that have a built-in battery backup. They also report when there's a loss of mains power. These cost about $25.