How are My Solar/My Electric totals calculated

Hi everyone,

I’ve just started using Grafana and importing the data from EmonCMS into it via MQTT. Doing this with power1 and power2 means I can display current consumption and generation with ease.

I’m trying to work out how to display totals for consumption and solar generation in Grafana and I figured I should ask how EmonCMS works these totals out.

My interval for reading power1/power 2 is 10 seconds. I’m therefore assuming that EmonCMS takes a sum of each 10 second reading and then divides it by 6 to get an average consumption for the minute? It’s then just an extrapolation for how long the period is of data showing?

Or is there some other way it is done and if so, is it its own feed to so speak which I could publish via MQTT?

Hi Ewan,

Here’s what I’ve found on the Grafana OpenHAB forum:

SELECT INTEGRAL(*,1h) FROM your-measurement WHERE TIME >= now() - 30d GROUP BY time(1d)

The results it yields are very close to what my WattsOn energy transducer gives me.

Here’s an example:

Note that Wh in the upper graph reads 58.29 K and the Daily kWh figure in the lower graph (above the bars, near the arrow) reads 58.32, so not spot on, but quite close.

Wow, thanks Bill. Have you got a link to where you found that on the Grafana forum?

I thought it was the Grafana forum, but it was the Home Assistant OpenHAB forum. (need new “RAM”)

Thanks again Bill, much appreciated.

PS, it was actually the OpenHAB forum. You definitely need a RAM upgrade.

That and a new pair of glasses!

Could I ask a favour, could you paste your code for your graph here, I’m having issues getting mine working right so I’d like to have a look at what you did. Thanks.

2 Likes

My apologies. I cited the wrong example. I should have pointed you to this link:

Screenshot of the query as shown in my query editor:

Here’s the text as shown in my query editor after toggling edit mode:
`SELECT cumulative_sum(integral("value")) /3600 FROM "GENW" WHERE \$timeFilter GROUP BY time(1s) fill(null)`

Replace “GENW” with the name of your measurement. Include the quotes.

1 Like