kWh - only per hour not day


I’ve seen several guides on how to do daily kWh usage. I just need a per hour kWh usage. I have both InfluxDB and Emoncms setup. I’ll use whichever is easier to setup.

I have solar, so I’d like a running total of the kWh usage from the grid. I’ve setup something weird up that goes up when using the grid but down when the solar power is greater than usage… lol Not sure how I got that weird shit setup…

Any help is greatly appreciated.



If you have a guide for how to do daily with influxDB, you only need to change the query to group by hour instead of day.

The problem I am running into is that the solar pushes the value negative. Which isn’t accurate. How can I calculate the power I use from the grid without the solar production subtracting from the total?..

You can send an Emoncms input or influxDB measurement that is only positive values. Assuming you have two mains in a split-phase US type system called L1 and L2, you can create an output that is only the positive (import) intervals with:

(L1 + L2) MAX 0

Another approach is to log and accumulate only the positive intervals using an Emoncms process list.

Ah ok. I have Main1 and Main2. It is a 400 amp service with 200 to the house and 200 for the solar system. So unfortunately I can’t monitor the 400 amps directly because of the way the wiring is done. I can’t even see where they combine. I ended up putting 2 CTs on the house mains calling them Main1 and Main2. With one CT for solar.

So I should be able to do this…

((main1 + main2) - solar) MAX 0

Does that look correct?

Thanks again I appreciate the help!

If the solar feeds in upstream of the mains, and you have “double” checked for the solar CT, that looks like it will capture the net import intervals.

Awesome that works! Thank you so much!

One last question… How can I setup a feed in emoncms that shows the total kWh usage for the current hour. In other words - let’s say it is 5:30 then it should show the usage from 5:00 to 5:30 only.

I’m sure there’s some way to do it, but TBH I don’t use Emoncms all that much. You can get that metric directly from IoTaWatt using the query API or via Graph+, but you’ll need to look deeper into Emoncms for exactly how to do it there.

Do you have any experience with Home Assistant and how I could use the query API from it?

I don’t have experience with HA, but there are users who do. Some have integrated the status API, which is not documented. Others have uploaded to influxDB and query that for the HA data. One user has done both and also used query.

You might also search the HA forum for IoTaWatt. I believe there are some documented interfaces there as well.