PZEM component - measured values should expire when AC is disconnected!

Popular AC energy monitor PZEM-004T is powered from AC side. In result when measured AC power is lost, values are not updated at all and esphome still remembers last received values and in result e.g. in HA frontend you still see “230V” instead of “not available” or just “0V”.

Do you know any method how to add expiration time here, similar as it is in mqtt sensor?

Are you talking about a situation where the PZEM-004T loses power but the ESP is still powered? In my case it’s all powered from the same source, so it indeed does go unavailable when power is lost (although that means my network is also down, so it doesn’t really matter anyway).

Yes, exactly such a situation: ESP is still powered, but PZEM not. My PZEM measures something specific, not a whole power.

Gotcha. Any reason you can’t power it from the same circuit it’s measuring? That’s what I ended up doing, partly because I needed a new outlet to power the ESP anyways and also to make it foolproof to isolate it all during install/anything else.

Mostly due to fact that in my case PZEM is only a part of bigger device and it measures just one (important for me) AC output controlled by this device. So it has to be independent: working ESP still performing other functions and able to report that there is no power on this line (it can be loss also due to other reasons).

Totally makes sense. I’d actually considered putting my ESP on a battery (if I ever put my WiFi on a UPS) so I could track outages. Interested if you ever find a good solution, since I wasn’t aware this would happen when AC power is lost.

You could open an issue here:

If the sensor goes off-line it really should report unavailable.

Done, issue #4652
Maybe anybody have an idea, how to workaround it? Can I detect somehow a presence of this module via UART as an additional sensor?

1 Like

FR is reported one year ago and no reaction? So it seems, rather no chance for bug fix in the integration… It’s a pity, because it should be easy to make such a change.

I was thinking about such hardware solution by own, but unfortunately I found this problem after building my device, not during, dismounting them and making such modifications is currently a bit too complicated :slight_smile:

At this point in time over 1000 open feature request do exist. On the other hand also more than 1000 feature request are closed but indeed, opening a FR is easier than closing it :wink:

Well - quite the opposite! It’s a open source project so everybody (including you :wink:) can “fix” this (or add the wanted function) and send the pull request upstream :rocket:

Maybe there is way to work’a’round it by software with filters or something :thinking:

yes, little search gives you this solution @Jarek_P

Good idea, thx!