I’ve written up in more detail how I track energy use using SQL sensors and accumulator templates here: