Background
I am using a Particle IOT controller that outputs a concatenated string of variables separated by “_”. I am having trouble parsing this string into separate variables and displaying them in influxdb cloud. Ultimately, I would like to be able to plot these variables against each other for analysis.
I can get the variables separated out into columns in a table but do not know where to begin on how to store these in influx db cloud as separate variables for analysis later.
I tried looking through this forum as well as searching the web but have not found any obvious things to try. Has anybody accomplished something similar and can point me in the right direction?
Output from Particle controller:
4_1_0.000155_0.000154_0.000000_1.100000_0_1614201642_0_0.000000_64_1000.000000_0.400000_0.010000_1_1614208748
Initial attempt at a parsing query:
//necessary libraries to import
import “strings”
import “experimental/array”
//select bucket and filter to correct string variable
from(bucket: “GENII”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: ® => r["_measurement"] == “tag1=port”)
|> filter(fn: ® => r["_field"] == “PortOutputString”)
|> filter(fn: ® => r[“tag2”] == “output”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
//table formatting - columns for each variable after parsing string
|> map(fn: ® =>
{
parts = strings.split(v: r[“value"], t: "”)
return
{
port: parts[0],
active: parts[1],
rateactual: parts[2],
ratetarget: parts[3],
ratedifference: parts[4],
totalO2: parts[5],
state: parts[6],
webupdatetime: parts[7],
webresetflag: parts[8],
pressure: parts[9],
timebetweendoses: parts[10],
tanksize: parts[11],
mgLmonth: parts[12],
dosesizeaverage: parts[13],
doseneededflag: parts[14],
lastdose: parts[15]
}
}
)
Current Output:
Currently I can output a table with columns for each variable separated out.