I have what I had thought was a simple use-case, but its turning out to be quite difficult. I have 2 influxdb buckets, one that logs my electricity meter price, and day vs night rate, and another than logs the energy being imported.
what I would like to do is combine these to generate graphs of the amount of energy use on day-rate and on night-rate.
I can query the data with the following flux commands:
Get night-tate (boolean)
from(bucket: "home")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] == "Is NightRate")
|> map(fn: (r) => ({r with _value: strings.toLower(v: r._value)}))
|> toBool()
|> toFloat()
Get Energy Imported
from(bucket: "PV")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "PV")
|> filter(fn: (r) => r["_field"] == "Total_Energy_Purchased")
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> difference()
These return a different number of rows - 2 in the first query and 24 in the second (for a day).
I basically want to multiply one by the other so it shows the usage only when day-rate is a 1. Any ideas how this can be done?