Are you sure that is the correct & accurate way to convert power to energy.
The method I use (rightly or wrongly) is to use node-RED to calculate the W/seconds (joules) by multiplying the time between data points by the power, divided by 3600000.
I save that value to influx database.
Then, to calculate the the energy used per day, per hour or over any other time period, I simply
sum() the values together.
I’ve compared the results with the values recorded in emoncms, and they appear to be accurate.
// Find time since last datapoint update
// note - msg.time is a epoch timestamp fed in via flow
var updateTime = msg.time;
var lastTime = flow.get('lastTime2')||updateTime;
var t = updateTime-lastTime;
// Get the values
// Energy calculations
var calSolar = (t*solar)/3600000;
var calDivert = (t*divert)/3600000;