Hi,

I’m trying to get the cost of charging my EV from grid on a monthly basis.

I have a solar array but during winter I often switch from solar to grid. So I would like to create a sensor that can calculate the total amount of energy used from grid not from solar to charge my EV, knowing that when I am on solar power, the grid energy consumption = 0. I never have both at the same time.

What I have:

- a sensor from my solar inverter for output power
- a sensor from my grid output power
- a sensor from my wallbox charging station added energy
- a binary sensor from wallbox when EV is charging
- a sensor for the actual price per kWh.

What I need:

- a sensor that is doing the following:

WHEN ev_charge is ON

IF grid_output_power > 0

calculate the increasing total on a monthly basis from wallbox_added_energy and multiply by price per kwh.

I am not new to ha and programming but in this particular case, i don’t know where to start, some help would be much appreciated.