EV Energy Counter

I’ve got an idea but I’m not sure how to tackle it.

I got an EV charger that is summarizing the energy used to charge my EV. This counter is reset, when I unplug the car.
I also has different modes to charge only with excess solar power or from the grid. (Eco and “Normal”)

image

What I want to achieve now it to have different timers which are summarizing energy used from solar and energy used from the grid.

Example:
Charger is in eco mode from 07:00 to 18:00 and charged 30kwh. After that I switch to normal and charge another 20kwh.
The Charged energy (this session) counter would show 50 and I want to have to counters: PV: 30kwh and Grid: 20kwh

Next day I’ll use the car (so the counter from the charger would reset) and I’ll plug it back to the charger at 15:00. Solar may charge the car for 10kwh and after that from the grid for 10kwh. Charged Energy (this session) counter will show 20kwh.

My helpers should show PV: 40kwh Grid: 30kwh

Hope you get the point.