MichaluxPL / Sofar_LSW3

Get MODBUS data from Sofar (K-TLX) inverter through LSW-3 or LSE module
GNU General Public License v3.0
99 stars 47 forks source link

Influxdb + grafana: Daily production panel shows negative values #37

Closed perepujal closed 2 years ago

perepujal commented 2 years ago

Hi, the current query (in grafana.ifdb.json, about line 850) gives negative values at start of each day, it can be addressed with a trick: "query": "SELECT ((difference(max(\"SolarProduction_Today\")) + abs(difference(max(\"SolarProduction_Today\")))) / 2) FROM \"InverterData\" WHERE $timeFilter GROUP BY time(30m) fill(null)",

The trick just gets the absolute value and adds it to the first value, so it zeroes the negatives, then it divides by 2 to get the original positive values again.

HTH Pere

MichaluxPL commented 2 years ago

Try this one: SELECT non_negative_difference(max(\"SolarProduction_Today\")) FROM \"InverterData\" WHERE $timeFilter GROUP BY time(30m) fill(0)

perepujal commented 2 years ago

It works, thanks :)