I have been trying to figure out If Statments in FluxLang for the last 2 days and I have gotten nowhere.
I know I must be messing up the syntax for Flux but I also want to know if I am even in the correct train of thought and if Flux can do this.
I would like to get the first and last data point of today, store it in a variable and then compare them together.
This is what I have tried :
firstVol = from(bucket: "HomeTank")
|> range(start: today())
|> filter(fn: (r) => r["_measurement"] == "Tank1")
|> filter(fn: (r) => r["_field"] == "Volume")
|> first()
|> map(fn: (r) => ({ _value : r._value}))
lastVol = from(bucket: "HomeTank")
|> range(start: today())
|> filter(fn: (r) => r["_measurement"] == "Tank1")
|> filter(fn: (r) => r["_field"] == "Volume")
|> last()
|> map(fn: (r) => ({ _value : r._value}))
I think this gives me variables that I can then use to compare with each other like this :
if firstVol < lastVol + 500 then "Tank was filled up"
else "Nothing filled up"
From what I understand mapping the variables gives me a value without the time stamp so I should be able to compair them ?
Or am I thinking too closely to Python or other programming languages for this usage ?
Any pointers would be of great help, this is a far way off from what I am used to in my projects.