Quantcast
Channel: InfluxDB - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 199

Derived values of an energy counter

$
0
0

Hi,

I am using Grafana Version 9.1.6 with a similarly old, unknown version of InfluxDB¹. In this Grafana/Influx installation, I collect the numbers of various energy meters. I usually read in the meter value of consumed energy (in Wh or kWh) and use the derivative function to get the “current” energy consumption (in W or kW). This has proven to work better than reading out the consumption values that some meters offer².

One of the meters is read via Modbus from the solar power inverter, and it is crippled by the fact that it only reports full kWh (but in Wh³), while the other meters usually report by Wh or even a fraction of an Watt-Hour. So, this counter stays at the same level for quite some time (with the reading staying the same, creating new database rows with the same value over and over) and then jumps by 1000. The derive function plots this as a series of zeroes followed by a huge peak.

(please disregard the units, they’re at least misleading if not plain wrong in the example)

Green: The raw meter value
Yellow: What derive makes from it.

I have deliberately screenshotted the queries with the graph.

The InfluxDB query for the green graph is

SELECT last("Val") 
FROM "TS00339" 
WHERE $timeFilter 
GROUP BY time($__interval) fill(previous)

The InfluxDB query for the yellow graph is

SELECT derivative(last("Val"),1h) 
FROM "TS00339" 
WHERE $timeFilter 
GROUP BY time($__interval) fill(previous)

TS00339 is the time series that the appliance writes to InfluxDB, and “Val” is the column name also pre-set and unchangeable from the appliance.

I would like the yellow graph to average the power consumption.

Example: Let’s assume that the load takes 100 W constantly. That means that the meter value will advance by 1000, then stay at X for 10 hours and then advance by one thousand again. I’d like my green graph to show 100 W for the entire 10 hours.

Another example: Let’s assume that the meter has advanced by 1000 exactly at midnight for the last time, the load takes 0 W, except between 03:00 and 04:00 where it took 990 W (= 990 Wh) and then between 09:00 and 10:00 990 W again. At some time before 09:01, the meter will thus advance by one thousand, and I’d like Grafana to draw a horizontal line at just-a-bit-above-100-W (below? brain too foggy to get the direction right) for the entire time between midnight and 09:01.

Can I get my ancient InfluxDB/grafana combination to do this without changing the data preparation and without losing the existing data? Or do I need to plug some math between the Modbus and Influx intake?

Thanks for helping! I really appreciate that.

¹ and Updates won’t happen because it’s kind of an appliance in house automation
² because most meters just export a snapshot of the current wattage and not the averaged value between the last two reads, which is rather different if your load wattage changes quickly and radically
³ sick, I know, but unchangeable

10 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 199

Trending Articles