evcc-io / evcc

Sonne tanken ☀️🚘
https://evcc.io
MIT License
3.59k stars 661 forks source link

Potentially incorrect Charging Cost Calculation #11032

Closed changyang1230 closed 10 months ago

changyang1230 commented 11 months ago

Describe the bug

Hi, please see the attached photo below.

IMG_4516

I am wondering if the calculated "charger cost" of 2.7c is an over-optimistic calculation?

The way I see it:

I am guessing that the reason EVCC has produced 2.7c estimate is because it puts the car charging as the preferential user of the solar energy instead of my home battery, therefore of the 8.3kW solar production, 1.7kW went to the house, and 6.7kW went to the car. Therefore the car charging cost was calculated as (6.7 2.25+0.5 8.2)/(6.7+0.5) = 2.7c.

I wonder if this is an incorrect way of calculating the charging cost. If I wasn't charging the car, these solar excess would have gone to the battery first, there's no way I would have imported grid energy to charge the battery as this calculation is proposing.

Steps to reproduce

See above.

Configuration details

not relevant

Log details

not relevant

What type of operating system are you running?

Docker container

Version

v0.122.1

StefanSchoof commented 11 months ago

A similar topic: https://github.com/evcc-io/evcc/issues/9832

changyang1230 commented 11 months ago

Just had a look with google translate (don't speak german) - it's a different calculation issue.

I thought it's the natural order that solar should be considered to be used household consumption > home battery > car battery; as the first two are what get the solar when the car is not plugged in.

As it stands, the car charger expense is presumed to have used up the solar excess first (hence very cheap) before the home battery which is not really logical.

StefanSchoof commented 11 months ago

I think in that issue there is a link to the docs. Here the englisch version:

https://docs.evcc.io/en/docs/guides/setup/#savings-calculation

evcc assumes that the house battery is primarily used to store excess, self-produced solar power. If the house battery also discharges to satisfy other loads, or charges from grid supply, this assumption isn't always correct.

Looking in your screenshot I see that the battery is loading from the grid.

changyang1230 commented 11 months ago

I don't agree with this logic.

Let's break down what would have happened on 7/12/23 into two separate parallel universe:

  1. the universe where I am not charging EV
  2. the universe where I am charging EV

I think both of us would agree that the cost difference of the two universe would be the "cost incurred to charge EV"?

For reference: Feed in tariff: 2.25c Grid: 8.2c

In the first universe (no car charging). Solar production 8.3kW Consumption 1.7kW Battery charging 3.0kW (max of what my battery support) Grid export 3.6kW (this would have happened if I wasn't using it for the car)

In the second universe (with car charging): Solar production 8.3kW Consumption 1.7kW Battery charging 3.0kW (max of what my battery support) Charging: 7.2kW Grid import: 3.6kW

So the second universe, when compared to the first universe, I am losing the grid export for 3.6kW (hence 2.25c per kW), and I am also incurring the new grid import of 3.6kW (hence 8.2c per kW).

Therefore the calculation should have been (3.6 2.25+3.6 8.2)/(3.6+3.6) = 5.2c.

That "house battery is primarily used to store excess, self-produced solar power" is not relevant in my disagreement in how the cost calculation is over-optimistic, when we use the "two universe method to derive the true charging cost.

changyang1230 commented 11 months ago

By the way an additional comment here.

The battery is a hybrid battery where it has a maximum inverter of 5kW. Therefore, even though the solar production of 8.2kW, it can only convert 5 of it to AC and the rest is supplied to charge the battery.

Therefore there is this illusion of "i am charging the battery with grid energy" which is not really the case.

naltatis commented 11 months ago

The battery is a hybrid battery where it has a maximum inverter of 5kW. Therefore, even though the solar production of 8.2kW, it can only convert 5 of it to AC and the rest is supplied to charge the battery. Therefore there is this illusion of "i am charging the battery with grid energy" which is not really the case.

But this seems to be the issue here. I would have assumed that the charger would reduce power to not introduce grid import. Or did you set a min of 7.2kW?

\cc @premultiply

changyang1230 commented 11 months ago

That bit is intentional, my solar excess is not sufficient so I chose to fast charge with the cheap day time grid energy.

changyang1230 commented 11 months ago

Any more thought thought from @StefanSchoof or @andig now that I have explained my rationale in more detail?

premultiply commented 11 months ago

As this is an hybrid inverter: Have you set https://docs.evcc.io/docs/reference/configuration/site/#maxgridsupplywhilebatterycharging correctly?

naltatis commented 11 months ago

I guess our formula does not account for this scenario (AC limited hybrid inverter) yet, and it assumes that the home battery is only charged when house and vehicle are covered.

We'll have do dive in here and add test cases for your setup.

https://github.com/evcc-io/evcc/blob/master/core/site.go#L779-L784

\cc @MarkusGH

RTTTC commented 11 months ago

I do agree with @changyang1230 - for savings calculation car charging energy should be considered "last in line" to get solar energy, no matter what the reasons or settings are.

changyang1230 commented 11 months ago

Thank you so much for looking into this and understanding where I am coming from.

In the mean time may I check whether EVCC saves detailed logs of my previous charges? In other words, is there a way for me to go back to my previous charging cost calculations, look at the fine prints of minute-to-minute distribution of battery, solar, import, export etc, and manually change it to what I deem is the correct cost?

I am happy to do the analysis myself if there's a log that I can find.

naltatis commented 11 months ago

Depending on your configured log level you can see the individual values in stdout. Do build aggregates per charging session to calculate the price per charging session but these all all in memory. We only persist the result to db (sessions table in evcc.db) when charging is finished.

MarkusGH commented 10 months ago

The issue is in the green share calculation. With the current formula the green share is allocated to: 1) home 2) (loadpoints + battery charging). As there is an agreement that loadpoints should be "last in line", the correct calculation is: 1) home 2) battery charging 3) loadpoints. Proposed fix: https://github.com/evcc-io/evcc/pull/11545 Please note that greenShareHome + greenShareLoadpoints will not add up to 100% anymore if the battery is charged and greenPower > homePower.