How to measure ampere-hours with current- and voltage-meter PZEM-017 (virtual entity)

I have a PZEM-017, a digital DC voltage, current, power, and power consumption meter connected to ESP32. The following configuration provides Home Assistant with four entities.

sensor:
  - platform: pzemdc
    current:
      name: "PZEM-017 Current"
    voltage:
      name: "PZEM-017 Voltage"
    power:
      name: "PZEM-017 Power"
    energy:
      name: "PZEM-017 Energy"
    update_interval: 60s

What I need is to have a fifth entity in HA which would measure ampere-hours and would build historical graphs. I require it to measure the capacity of the battery through its discharging. Dividing Energy by the Voltage to get amp-hours is not the solution, because the Voltage won’t be constant.

Who knows how to «create» such virtual sensor basing on the existing ones?

Using an integration helper in Home Assistant seems like it would probably work for your needs.

Thank you very much! It works! :+1: