Here is a post in our wiki for a Meta Data Script to calculate kWh from a kW reading. It's not going to be as accurate as an actual kWh meter but sometimes all you have is kW.
http://infiniteautomation.com/wiki/doku.php?id=automation:script_examples
var lastKw = p1.lastValue(1);
var nowKw = p1.lastValue(0);
var period = nowKw.time - lastKw.time;
var kWlast = lastKw.value;
return kWlast / (3600000/period);