Influx db string

hello,

connecting influxdb with plc siemens en opcua if i try to send a string i receive this error

unsupported input type for mean aggregate: string

this is what i'm sending

28/4/2024 00:37:29node: debug 38
ns=4;i=8 : msg : Object
object
_msgid: "0501bfd033f6f0e2"
payload: "pluto"
topic: "ns=4;i=8"
datatype: "String"
browseName: "Productie"
statusCode: object
serverTimestamp: "2024-04-27T22:37:31.799Z"
sourceTimestamp: "2024-04-27T22:37:31.799Z"

thi is the query in influxdb

from(bucket: "Test")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "prod")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

can smeone help me please

Is the error appearing when you run the query to interrogate the database?

What are you expecting to be written to the database when you give it that data? If you read the help text for the influxdb out node you will see that that data will cause the string "pluto" to be written, which I suspect is not what you want.

hello Colin
i think this solved by taking away the last 2 rows of code in the query still testing i don't think i'm the one who can give solution here, maybe someone else with more skill can say if i did rght

I am trying to, but you have not answered the question

sorry i wantend to read a name of production in grafana dashboard that i'm receiving from plc

Ok, so for the example you were in fact attempting to write "pluto", in which case that is ok.

The error you were getting was telling you that you were trying to take the mean value of a set of strings (containing "pluto" for example) which obviously you can't do. For string type fields all you can do is read them as a set of records.

i'm electrician so i don't know so much abut coding i'm learning and sometimes i spend days to do something that other people do iin 1 second :slight_smile:

It takes me forever to wire up a plug :slight_smile:

Try excluding the |> aggregateWindow function in your Flux Query. Apparently the column of your value is not of type number (which can be aggregated) its rather of type string (which can't be aggregated).

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.