I have a few live power consumption sensors that I import into InfluxDB, then I use the following query in Grafana to calculate my cumulative power consumption over the day. How can I add the cumulative integer parameters in Home Assistant?
This is my query in Grafana:
"SELECT cumulative_sum(integral("value")) /3600000 FROM "autogen"."Grid_import" WHERE time >= 1549198800000ms GROUP BY time(10s) fill(null)"
So far in Home Assistant this works, but does not show the cumulative value.
sensor:
platform: influxdb
host: localhost
username: ****
password: ****
queries:
- name: influxdb_grid_import
group_function: last
unit_of_measurement: W
where: 'time >= 1544965200000ms'
measurement: "Grid_import"
database: iotawatt
field: "value"
This is the JSON from Grafana
"measurement": "Grid_import",
"orderByTime": "ASC",
"policy": "autogen",
"query": "SELECT last(\"value\") FROM \"autogen\".\"Solar\" WHERE $timeFilter GROUP BY time($__interval) fill(none)",
"rawQuery": false,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "integral"
},
{
"params": [],
"type": "cumulative_sum"
},
{
"params": [
"/3600000"
],
"type": "math"