Hello,
I’m trying to compute my energy costs using InfluxDB 2 and InfluxQL.
The Tempo option by EDF offers a tiered electricity pricing based on three colors (red, blue, and white), which represent high, medium, and low-demand days, respectively. These prices also vary between peak and off-peak hours, enabling subscribers to benefit from more favorable rates by adjusting their consumption according to these time slots and day colors.
This initial query returns the daily consumption in kWh for each period:
daily_kwh = from(bucket: "energy")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "linky" and r["_field"] =~ /^(bleu|blanc|rouge)_(h[pc])$/)
|> aggregateWindow(every: 1d, fn: last, createEmpty: false)
|> difference(nonNegative: true, columns: ["_value"])
|> map(fn: (r) => ({
_time: r._time,
_field: r._field,
_value: r._value / 1000.0,
}))
The prices are stored in the measurement linky_cost. Each day or period will have its own tariff. The field is the same as in the linky measurement. A new record will occur with each price modification.
I would like to write a query that is based on daily_kwh
, where _value
would be the cost for the current line. To determine the tariff, the range start should be 0 (to indicate searching from the beginning), range stop should be the _time
of the current consumption line, and we need to take the last value from linky_cost
for the field equivalent to the consumption field.
This query is posing an issue for me. Could you help me or provide some guidance.
Thank you,
Thomas
PS: as a new user, I can’t send attachment, but I can provide sample data if required