Build electrical consumption dashboard with plugs tat reset every day

  • What Grafana version and what operating system are you using?

Grafana docker (running in Unraid), latest version to date.

  • What are you trying to achieve?

I try to build an electrical consumption dashboard, I have 40 connected plugs, a mix of meross (wifi 310 plugs) and tuya (zigbee) plugs, mostly.

  • How are you trying to achieve it?

  • What happened?

I’d like to get guidelines in order to understand how to calculate the cost per plug :

  1. by setting up my per kWh price somewhere in order to make the math.
  2. by figuring out a way to convert meross reported Wh to Kwh, so I’ll end up with the “same” calculation for both plug models
  3. by figuring out how to calculate the consumption of the meross plugs who do reset every single day.
  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

one screenshot shows it all :

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.


  • Did you follow any online instructions? If so, what is the URL?

Well, I try to find inspiration from here, but I’m not using prometheus but influxDB, nor using grafana cloud, therefore I will have to build my dashboard from scratch (I guess?)

@raph1 Welcome to the Grafana Community Forum.

Are you using Flux or InfluxQL?

Hi and thank you ! :slight_smile:

The data I’m querying is located on an “old” influxDB 1.8 I’m running in a home assistant addon.

Therefore it is influxQL.

My goal is to migrate everything to a newly installed 2.x dockerized version (already running on my unraid server). :slight_smile:

I forgot to mention that I’ve already included the meross plugs in my HA dashboard, and that the calculation of the costs also is an issue, as you can see it is reset every day at midnight, here is how it looks like :

anyway, I plan to totally skip calculations inside HA, it’s simply not there yet. I want to keep the on/off switch capability, of course, but will move all my nice and fancy graphs to grafana. This is the reason why I’m making my first post here :wink:

I made some advancement, and finally figure out that influxdb is not feeding grafana as much as I’d like. But now I have another issue. I have devices, that are clearly in my queries list, that disapears from my dash !

I take this as an example:

We can see the the section “Salle a manger” has 7 lines. But I actually miss a few, if I do edit my panel, here is what I directly can see :

as you can see, the A query (Alexa) is in there.

If I go to inspector, I can clearly see some queries are NOT in the list. Actually, A, C and E are missing.

What is the reason therefore ??

Hi @raph1 I noticed in your queries that you are grouping by 1s. Is that necessary? How often is your plug / sensor data being collected? If it is, say every 1 minute, then change the grouping to 1m and see if that helps.

Hi grant, as far as I can see, it looks like the meross plugs updates every 10s

I’ll try to increase this to 10s first, and see what happens.

Still, I don’t get this, even if no data is detected, each line should be there and reporting 0 W, right ?

My understanding acc. to this is that basic GROUP BY time() queries rely on the time_interval and on the InfluxDB database’s preset time boundaries to determine the raw data included in each time interval and the timestamps returned by the query. If you set it to 1s, it creates 10 times more intervals than you have.

I will follow your advice and start with 60s, see if things reapears. If they are, I will then try to go back to 10s, etc.

I’ll keep you posted ! :slight_smile:

1 Like

Hi @grant2 ,

I’ve advanced a bit and I’ve added all my switches and lights in a “real time” dashboard. I switched to 10s.

Looks “ok” so far, as I can see the Watt values been updated when I start to use electrical devices.

now, I started building another dashboard where I’d like to get the daily consumption of all these switches and lights, here is how it looks when I do pick “last 24h” in grafana :

problem is, I definitely can see the problem here. The unraid server I’m using consumes an average of 150W 24/7.
As comparison, the “pacman” lamp uses 18W.

As you can see, for the same period (24h), the pacman lamp reports 7.78W and the unraid server, only 2.03W.

the reason is what I listed above. The unraid server runs on a meross plug that do reset its KwH values every day at midnight, while the tuya plug actually reports the total kWh usage since I plugged it.

What is the magic trick to make sure the values reported by my meross plugs are not reset every day ? Somewhere, I should have a way to “take yesterday value” and sum it to the next day right ?

I’m a little lost here :frowning:

The problem as I understand matters is one device resets every 24 hours and the other is a cumulative value of energy.

I would suggest you just use the difference between the first and last value as it will return the same result for both.

For example say MEROS is 25,25… and PACMAN is 0,25,50…
Then 25 -0 = 25 and 50-25 = 25

For the PACMAN you can do a running sum so 25,25,25 becomes 25,50,75
I think it is called the cumulkativeSum() function. See

I think that @raph1 is not using Flux. So he’d still follow the above advice, but using InfluxQL.

Hi gents,

So, I am using Flux. but as this is a very old topic, I actually sorted this out by created multiple utility meters in HA.

This is now fixed ! thanks for the support as always ! :slight_smile: