ioBroker / ioBroker.influxdb

Store history data in InfluxDB (not for Windows)
MIT License
36 stars 25 forks source link

HttpError: runtime error @4:12-4:122: filter: type conflict: bool != string #372

Closed tipp88 closed 10 months ago

tipp88 commented 10 months ago

History for states of type String are not shown. A type conflict error is thrown.

image

image

image

Apollon77 commented 10 months ago

The error means that there seems to be a value in the DB which is NOT a string, but a boolean and so selection do not work ...

Else pleas eenable debug log for the adapter AND turn on enhanced logging for this datapoint in the config and post a debug log from such a query ... Then we maybe can look at the reasons for the error

Marc-Berg commented 10 months ago

The adapter tries to find out whether the data type is "boolean" by checking whether at least one content is "true" or "false". This query is incorrect, a filter is missing here.

Incorrect:

from(bucket: "iobroker") 
 |> range(start: 1999-12-31T23:00:00.000Z, stop: 2025-12-01T14:31:44.004Z)
 |> filter(fn: (r) => r["_measurement"] == "0_userdata.0.example2" and contains(value: r._value, set: [true, false])) 
 |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") 
 |> group()

Correct:

from(bucket: "iobroker") 
 |> range(start: 1999-12-31T23:00:00.000Z, stop: 2025-12-01T14:31:44.004Z)
 |> filter(fn: (r) => r["_field"] == "value")
 |> filter(fn: (r) => r["_measurement"] == "0_userdata.0.example2" and contains(value: r._value, set: [true, false])) 
 |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") 
 |> group()

As a result, the columns "ack" and "value" are mixed and lead to the error message described.

https://github.com/ioBroker/ioBroker.influxdb/blob/145e59a8d3f1bb0744298e4376bdb0008532b5ce/main.js#L2373

tipp88 commented 10 months ago

The error means that there seems to be a value in the DB which is NOT a string, but a boolean and so selection do not work ...

Else pleas eenable debug log for the adapter AND turn on enhanced logging for this datapoint in the config and post a debug log from such a query ... Then we maybe can look at the reasons for the error

It is a completely new object which has been created as String and logging activated as String. There is not a single value stored as bool, it only 7 values at all: image

image

I think Marc already found the issue. Thanks

Apollon77 commented 10 months ago

PR merged, thank yopu, preparing release