Calculate and display Energy (kWh) use from smart meter energy readings

Hello All

A bit of guidance please

I have a working node-red/influxDB/Grafana stack which is receiving data and storing data from a number of sensors. One of the sensors is a smart energy meter which is providing a reading of total energy every 10 seconds (See image) As you can see, this is a read of total kWh consumed since birth. These readings are stored in series Total.Energy
image

I would like to draw a graph (Bar chart) of total kWh consumed per day, but have no idea where to start with the query.

Suggestions and constructive input gratefully received

Hi Andy.

One way to do this would be to use the difference node from here: https://flows.nodered.org/flow/63dc333242b636ce42472cbf0ed1ab0d

It takes the latest reading and substract it from the previous reading.

Afterwards you can use the inject node to run once every hour (if you want hourly consumption). You should try it out to see how it works.

When above is suited to your needs, you will properly need to save these values somewhere. I use InfluxDB myself. I store the consumption and the meter readout aswell in my db.

Maybe it’s possible to store just the meter value and do some querying, but this I don’t know how to do.

Another option is to calculate the difference in the query from the totals stored in InfluxdB.

I do something very similar with NodeRed and Influx. There is no need to save daily totals in the database, instead you calculate them using the difference() function available in Flux.

See my post here:

Hi Andy,
I’m using a tool called vzlogger on a Raspberry to read data from my Smart Meter to write it into an InfluxDB. The data inside my InfluxDB looks like this:

name: vz_measurement
tags: unitname=Home, uuid=104db138-7238-4f40-ada5-7aacd5b99e9d
time                mean
----                ----
1590796800000000000 2714.87

I use the following to create a graph with data points every 10 mins to display the power consumption:

SELECT derivative(mean("value"), 10m) *1000 FROM "autgen"."vz_measurement" WHERE
("unitname" = 'Home') AND $timeFilter GROUP BY time(10m) fill(none)

So in your case it should be something like this:

SELECT derivative(mean("payload"), 10m) *1000 FROM "Retention"."Name" WHERE
("node" = 'aa42d6a8.4bb338') AND $timeFilter GROUP BY time(10m) fill(none)

Let me know if it worked…

I changed my solution to the one written below by @koenwindey.

Thanks :wink: