Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't calculate SUM with FLUX #372

Open
KlausH1967 opened this issue Feb 24, 2025 · 0 comments
Open

Can't calculate SUM with FLUX #372

KlausH1967 opened this issue Feb 24, 2025 · 0 comments

Comments

@KlausH1967
Copy link

KlausH1967 commented Feb 24, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant