I’m having some trouble getting a flux query to work to InfluxDB 2.0. Here is my code to query:
sensor:
- platform: influxdb
api_version: 2
ssl: false
host: 192.168.x.x
port: 8086
token: ***
organization: ***
bucket: acurite
queries_flux:
- range_start: "-1d"
query: '|> filter(fn: (r) => r["topic"] == "esp-barometer/sensor/sea_level_pressure/state")'
name: "Sea Level Pressure"
unit_of_measurement: "inHg"
group_function: mean
The error that I get is:
haqa | 2021-11-03T09:32:05.868108084Z 2021-11-03 05:32:05 ERROR (SyncWorker_5) [homeassistant.components.influxdb.sensor] Could not execute query 'from(bucket:"acurite") |> range(start: -1d, stop: now()) |> |> filter(fn: (r) => r["topic"] == "esp-barometer/sensor/sea_level_pressure/state") |> mean(column: "_value")' due to '(400)
haqa | 2021-11-03T09:32:05.868611376Z Reason: Bad Request
haqa | 2021-11-03T09:32:05.868670497Z HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'Vary': 'Accept-Encoding', 'X-Platform-Error-Code': 'invalid', 'Date': 'Wed, 03 Nov 2021 09:32:05 GMT', 'Transfer-Encoding': 'chunked'})
haqa | 2021-11-03T09:32:05.868755612Z HTTP response body: b'{"code":"invalid","message":"compilation failed: error at @1:61-1:63: pipe destination must be a function call"}'
haqa | 2021-11-03T09:32:05.868817751Z '. Check the syntax of your query.
The reason is pretty clear, there is an extra pipe getting inserted between the range and the first filter.
Any thoughts why or how to prevent this?