Displaying KWh from KW data in a variable time frame

Hi, I’m new to Grafana and are trying to solve the following:

How do I display kwh from kw measurements in a variable time frame?
My setup is as following: I have a power meter giving me total power for my house and I have a lot of power sensors all around my house. That gives me total power, known power usage and unknown power usage. What I’m interested in is doing kwh measurements in the unknown power usage to try to analyse what euipment uses that power and how much power is used when the equipment is on.
One example is when charging my car, that makes a very distinct curve in my unknown power usage graph that I can isolate to measure approximately how many kwh is used by the car and then calculate the cost for charging my car.

Any ideas?

I think you need to do sub queries. I mocked this up based on an interface counter I use for routers.

SELECT sum("kWm") FROM
	(SELECT mean("value"), 10s) as kWm FROM "kWh" WHERE ("entity_id" = 'bmw_i3') AND $timeFilter GROUP BY time(60s) fill(null))
GROUP BY time($__interval)

The inner query returns kilo Watt minutes to the outer query. If you change the $__interval to 1h, you should have kWh.

As far as I understand, your suggestion will only work if time is set to 1h. What I’m trying to acheive is I want to analyse a specific time period based on my unknown power usage:

I zoom into the area marked in the picture to calculate poweusage within that time frame:

My idea is to use total mean power usage every minute within a time frame and divide that with how many minutes are in the time frame. But I have no idea how to do it…