# There is a way to split an energy flux in the two directions?

Hi everyone! I’m wondering if is possible to split an energy flux entity in two different entities, one measuring the energy flowing in one direction and the second for the energy in other direction.
Let me make an example:
In my Home Assistant I have configured two energy meter, one for measuring the energy (kWh) from my solar inverter (A) and the second measuring the energy (kWh) consumed by my house (B). Now, since Energy tab requires two entities which represent the energy from the grid and the return, I’m wondering if I can calculate those two from the two energy meter that I have. In fact, if I create a sensor template whose value is (A) - (B) I have the amount of eccess energy produced or (B) - (A) I have the extra energy that I needed from the grid. But in this way I can’t know how much energy I take from the grid and how much I returned, basically because if for half of the day I have returned, let’s say, 10kWh and suddedly starts raining and all the energy from the second half of the day comes from the grid, this entity starts to decrese, instead of freezing at 10kWh and a second counter starts to increse (energy buyed from the grid). So I need a way to calculate the flow, in both direction. Is possible in some way?
Thanks to all!

Yes using utility meters. Create two template sensors:

Energy to grid:

`if A - B > 0 , A - B, else 0`

Energy from grid:

`if B - A > 0, B - A, else 0`

Then feed these two sensor to two utility meters with daily cycles:

Use the utility meters in your energy dashboard.

1 Like

Brilliant!
I was convinced that if the sensor feeded to the utility_meter decrease, the utility_meter also decrease, but is not😁.
Thanks a lot!

Hi, This assumption could be right when B ( grid meter ) show you only consumption, but at least in my case I have also A ( meter for PV inverter ) and B ( grid meter ), but B is not bidirectional so When B=100w I don’t know if it is for example:

1- 400w ( real energy consumption ) - 300w ( PV generation )
2- 200w ( real energy consumpiton ) - 300w ( Pv generation )

Any idea?

It’s not an assumption. It was the answer to the specific details provided. This is a solved topic. You probably should have started a new one, but anyway…

For your completely different case:

Energy from grid:

`Meter B`

Energy to grid:

`You do not have sufficient metering to determine this. Unless you also know the household total load.`

And we were talking about energy (kWh) You are talking about power (W or kW).