I have a device, attached to a smart plug and controlled by HA, that runs for couple of hours a day and I want to track how much energy it needs in that time.
I already set up automations to track the time the device is switched on and off in order to calculate the total energy required in that timeframe:
If the device is turned on, I store the current energy meter reading and current time into helpers
If the device is turned off, I fetch the current energy meter reading, calculate the difference and also calculate the time the device was on
Now I know the total energy consumption for the timeframe and also the average power consomption in the timeframe.
What I would like to know now is the average per run of the energy consumption.
I figured, an easy way would be to calculate the average in an input_number helper, by setting the new value to the old value plus current consumption divided by two.
I wonder however, if there is a better way to do this, and also be able to track the old values? I.e., is there something like a “list helper” where I can add values and calculate averages/min/max/… later on?
I guess I was assuming the “meter” was built into the smart plug… so the value only increases when it’s turned on. In that case the Utility meter integration will handle the cycling.
If that’s not the case, but the end device consumes a predictable amount of energy over time, you may want to check out PowerCalc.
The device runs sometimes several times a day, for an unknown time and requires different power each time.
Thus, I want to know what the average energy was per run and not per day.
I noticed however, that with the number of activations and the total energy consumption, I can already calculate an average.