Hello!
I have a query that wont return correct values when using the time picker in grafana. If I select “today” or even
Only if I do this the values will return correct, what am I missing?
import "timezone"
option location = timezone.location(name: "Europe/Stockholm")
from(bucket: "homeassistant/autogen")
|> range(start: 2023-10-10, stop: 2023-10-12)
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["entity_id"] == "vattenberedare_energy"
or r.entity_id == "inverter_ac_energy"
or r.entity_id == "studioserver_energy"
or r.entity_id == "pump_energy"
or r.entity_id == "soluttag_energy"
or r.entity_id == "tv_bank_energy"
or r.entity_id == "shelly1pm_kyl_frys_energy"
or r.entity_id == "inverter_500v_ac_energy"
or r.entity_id == "shelly1pm_husbelysning_energy"
or r.entity_id == "sovrum1_element_energy"
or r.entity_id == "satoshi_energy")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: 1d, fn: last, timeSrc: "_start")
|> difference(nonNegative: false, columns: ["_value"])
|> filter(fn: (r) => r._value < 300)
|> filter(fn: (r) => r._value > 0)
if I try below the values will be recorded 24h from the time now() so that will be wrong I guess
|> range(start: -1d, stop: now())
if I try below the values will be wrong, (lower values from a forever increasing counter)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
also if I add below to the query without the specified timerange in the first example I will get “no data”
import “timezone”
option location = timezone.location(name: “Europe/Stockholm”)
also I checked the timezone in the browser that shows correct, it is almost like the grafana time picker wont collaborate with the time picker in the flux query??