Best practice to keep state of impulsed base energy counter

Hi, I am new and have a absolute basic question.

I receive the impulses from an Eltako DSZD15 energy counter in my home assistant. Each impulse is 1/100 kWh. I only get an impulse, not the current state of the energy counter, so each MQTT message has the value “1”.

Now I want to keep track of the energy counters total count by starting with a value in home assistant and each impulse increases this value by 0,001 kWh.

In the end, I want to be able to see power usage in a graph and the power usage by minute, hour, day, week, month, year etc.

So the basic questions are:

What is the best practice to keep the state of the energy counter in home assistant?
What do I need to do, to be able to answer questsions like: “What was the power usage per day last week”?

Thanks for any help.

Hi,

I suggest to use VAR-History integration.
You can define a variable as retained ( Restore on restart)
Having your pulse triggering an automation which increment the variable…