Calculate power consumption that varies every second
If \$P(t)=v(t)\cdot i(t)\$ is the power, then the energy is

\$
E(t) = \int P(t)\,dt = \int v(t)\cdot i(t)\,dt
\$

The method that you apply is an approximation to the exact energy calculation.It depends on the accuracy you want in your results, if it helps or not.

If you look at integrating, it is formed by the product of voltage and current multiplied by \$dt\$. The time differential is an infinitesimal increase.
In your case, the time between samples are not infinitesimal, so you can expect an error on the value of energy calculated. If the interval between measurements is kept uniform, you are using the rectangular approximation to the solution of the integral. You should evaluate whether the results you get with the generated error is acceptable.