Cumulate Total kWh consumption without reseting

Hi !

I’m using Grafana v9.5.2 and InfluxDb 1.8 (InlfuxQL) on Home Assistant

I’m trying to get a total kWh consumption on this visualization, the issue is that I use an esp32 that can’t store any data, so if for some reason I lose connection the data resets like shown on the screenshot.

Idealy I’d want it to be like that :

Here’s the query I have right now :

SELECT mean("value") FROM "autogen"."kWh" WHERE ("entity_id"::tag = 'emon_cal_house_kwh') AND $timeFilter GROUP BY time($__interval) fill(null)

How could I achieve that ? (note that I also have immediate watt consumption data refreshing every 10sec.)

I’m a total newbie to all of this sorry in advance if my question is silly