Calculating grid only charged energy costs

I’m searching for the right way to calculate the grid only charged energy of my electric car to get electricity costs for a charging session.
I’m using go-eCharger wallbox, Shelly 3EM for grid meter and EVCC to control charging process correctly.
So, I can identify when grid power or solar power from my Huawei Sun2000 is used for charging.
How is it possible to save the grid only charged energy time deltas in a variable or somehow to have a live energy/cost sensor? I’m searching for the right approach…
I could use values from InfluxDB also.

Use a utility meter with two tariffs. One for solar, one for grid. Use an automation to switch the tariffs whenever the charging source changes.

Thanks for your quick response. Didnt think about that and sounds good. I will give it a try.

Okay. Im already using utility meters for monthly charged energy and costs, but how to get values for one charging session. Cycle have to be something like “session” or “custom” with a start and end time.

Do they have tariffs to differentiate the source of charge though?

Got it. Thanks! :smiley:

Implemented four tariffs with the four EVCC “charging modes”:

  • off
  • now
  • minpv
  • pv

“off” seems not to be a valid tariff for utility meter:

Error executing script. Unexpected error for call_service at pos 1: Option off not valid for goecharger_energy_yearly

Guess I have to implement a template to change “off” to “offmode”.

Put it in Quotes:

  tariffs:
    - 'off'
    - now
    - minpv
    - pv

off and on are booleans unless you quote them.