这是indexloc提供的服务,不要输入任何密码
Skip to content

Can't calculate SUM with FLUX #372

@KlausH1967

Description

@KlausH1967

Hello,
I try to create a diagram to compare to timeframes by using timeShift in FLUX-Syntax.

When I'm using InfluxQL I get the data in correkt form.
Syntax:
SELECT sum("value") AS "sum_value" FROM "statistik"."autogen"."kWh" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "deviceName"='solaranlage_erzeugung' AND "duration"='h' GROUP BY time(2h) FILL(null)

By usind FLUX I get the message: "panic: runtime error: invalid memory address or nil pointer dereference"
Syntax:
from(bucket: "statistik/autogen")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["deviceName"] == "solaranlage_erzeugung")
|> filter(fn: (r) => r["duration"] == "h")
|> filter(fn: (r) => r["_field"] == "value")
|> group(columns: ["field"], mode:"by")
|> aggregateWindow(every: 2h, fn: sum)

The same query works fine to calcualte the max-value:
from(bucket: "statistik/autogen")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["deviceName"] == "solaranlage_erzeugung")
|> filter(fn: (r) => r["duration"] == "h")
|> filter(fn: (r) => r["_field"] == "value")
|> group(columns: ["field"], mode:"by")
|> aggregateWindow(every: 2h, fn: max)

Systeminformation:
Version | core-2025.2.4
Installationstyp | Home Assistant OS
Entwicklung | false
Supervisor | true
Docker | true
Benutzer | root
Virtuelle Umgebung | false
Python-Version | 3.13.1
Betriebssystem-Familie | Linux
Betriebssystem-Version | 6.6.62-haos-raspi
CPU-Architektur | aarch64
Zeitzone | Europe/Vienna
Konfigurationsverzeichnis | /config

Addon:
InfluxDB (5.0.2),
Grafana (10.4.2),

At the logfile I found following line:
time="2025-02-24T21:44:34+01:00" level=info msg="Response: Internal Server Error" component=server method=POST remote_addr="127.0.0.1:44268" response_time=687.99701ms status=500

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions