Can't get Statistics Total to work for sensor

I want to find out the total amount of energy (integral) going through an INA219 sensor over a period of time. The power data is coming in via MQTT and seems to be working.

sensor.charge_monitor_0x40_power

I have tried to follow the instructions for how to configure these statistics in the configuration.yaml file, but I can find any of the output from the total sensor. This is what I have put in my configuration.yaml file.

mqtt: !include mqtt.yaml

sensor:
  - platform: statistics
    name: "Energy Discharge 0x40"
    entity_id: sensor.charge_monitor_0x40_power
    state_characteristic: total

binary_sensor:
  - platform: ping
    host: google.com.au
    name: "Google.com.au"
    count: 2
    scan_interval: 15

I have left the link to the MQTT file in plus the binary sensor in case I have formatted something wrong with these and they are impacting on the problem. Thank you for your assistance.

You cannot total power to get consumption, you need to do an integral (total area under the graph of power). The “Integration - Riemann sum integral sensor” helper can do this for you. Leave the “Integration method” as is (unless you understand it, which I don’t) and set the “Metric prefix” to “k” to go from power in “W” to consumption in “kWh”.

1 Like

Thanks for you help with this Michael.

It looks like I was doing it all the wrong way. I have managed to get the “Integration - Riemann sum integral sensor” working.

Thank you again.