- What Grafana version and what operating system are you using?
Grafana v10.1.1 (0cfa76b22d) on Ubuntu 18.04
The database I’m using is InfluxDB.
InfluxDB v1.7.6 (git: 1.7 01c8dd416270f424ab0c40f9291e269ac6921964)
Chronograf Version: 1.7.11
Grafana v10.1.1 (0cfa76b22d)
I plan to upgrade InfluxDB to version 2 or 3, so if it’s necessary to do so, please let me know.
Example of Watt-hour (Wh) data retrieved from InfluxDB.
I’m trying to retrieve kWh consumption on the left side and convert it into euros on the right side for different periods: current, last 24 hours, last month, and last year (365 days). I believe I can figure out a solution for months and years, but I need assistance in finding the best query for the current period and the last 24 hours.
Currently, the query I’m using to calculate consumed WattHours in the specified time range appears to be correct:
SELECT MAX("Energy [Wh]") - MIN("Energy [Wh]") as "Consommation sélectionnée (kWh)" FROM "watts" WHERE ("host" = 'PZEM-004t-v3-1') AND $timeFilter
However, I’m struggling to convert this value into euros on the left panels, and it seems like the displayed values don’t match my expectations.
Here’s the query I attempted, but I’m not sure of its accuracy for converting to euros:
SELECT ((MAX("Energy [Wh]") - MIN("Energy [Wh]")) / 1000 * 0.145 ) as "Consommation sélectionnée (kWh)" FROM "watts" WHERE ("host" = 'PZEM-004t-v3-1') AND $timeFilter
I’m also trying to determine if it’s feasible to obtain the cost of consumed watts during off-peak (0.1672/KWh) and peak hours (0.2285/KWh) based on the time within the period (e.g., peak hours from 07:30 to 23:30 with a rate of 0.2285/KWh), and the same for off-peak hours (as shown in the screenshot). Then, I would like to use transformation functions to aggregate both and obtain an accurate total.
I hope I’ve provided enough details for you to help me achieve this.