If im correct the PZEM004 is powered by mains and not the esp, it’s optocoupled on the communication lines between ESP and PZEM004.
So if power is cut then the PZEM004 is off and the last value will be the last value ESP received.
I think I have seen someone doing mods on the PZEM004 to be powered up by the 5v from espmodule or some thing.
edit: Think I was wrong, How to use PZEM004T Energy Monitor with esphome
I have not read all, but looks like it was more that the PZEM004 uses 5volt and ESP uses 3.3volts.
But does anything get logged, errors etc when the power is off?