Hi@all,
I converted my InfluxDB from 1.xx to 2.61.
Also I upgraded from Grafana 7 to 9.3.2.
My Problem is a Panal where 2 values should be displayed.
One value is logged negative to influx.
So in my privious version I could add math and *-1 to correct that value.
But what do I have to do here with the flux language ??
the fronius.0.powerflow.P_Load value is negative and should be converted to positive…
from(bucket: “iobroker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “fronius.0.powerflow.P_Load” or r[“_measurement”] == “fronius.0.powerflow.P_PV”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)
thank you for the aswer.
unfortunatelly I don´t know how to insert this into my flux because of the two values…
Can you help me out ?
have you read the whole documentation of map posted above? and what have you tried and where is it failing?
grant2
January 5, 2023, 9:32pm
5
@backons : Here is a hint. If you wanted to convert the values to degrees F, you could insert this line before the aggregateWindow
function:
|> map(fn: (r) => ({r with _value: r._value * 1.8 + 32.0}))
when I insert this than an error:
invalid: runtime error: type conflict: int !=float
is occured
from(bucket: “iobroker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “fronius.0.powerflow.P_Load” or r[“_measurement”] == “fronius.0.powerflow.P_PV”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> map(fn: (r) => ({r with _value: r._value * -1 }))
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)
1 Like
grant2
January 6, 2023, 12:30pm
7
Does changing it to -1.0 help, like this?
|> map(fn: (r) => ({r with _value: r._value * -1.0 }))
that works without error.
But it goes on both values and I have one negative and one positive.
So in this case negative one becomes positive and the postive one is now negative.
Only the value fronius.0.powerflow.P_Load should be turned from negative to positive.
grant2
January 7, 2023, 12:25pm
9
Can you separate into two queries, i.e.
from(bucket: "iobroker")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "fronius.0.powerflow.P_PV")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: "PV")
from(bucket: "iobroker")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "fronius.0.powerflow.P_Load")
|> filter(fn: (r) => r["_field"] == "value")
|> map(fn: (r) => ({r with _value: r._value * -1.0 }))
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: "Load")