evcc-io / evcc

Solar Charging ☀️🚘
https://evcc.io
MIT License
3.65k stars 678 forks source link

Tariff: add dynamic/zones charges to ENTSO-e #17417

Closed bartashevich closed 2 days ago

bartashevich commented 3 days ago

Fix https://github.com/evcc-io/evcc/issues/12371

Example for BZN|PT domain with feedin and grid:

tariffs:
  feedin:
    type: entsoe
    domain: BZN|PT
    securitytoken: xxxxxx
    charges: 0
    tax: 0
  grid:
    type: entsoe
    domain: BZN|PT
    securitytoken: xxxxxx
    charges: 0
    tax: 0
    formula: (price + 0.004 + 0.0028930 + 0.010)*(1 + 0.16) + 0.005
    zones:
      - days: Sun-Sat
        hours: 0-7
        price: 0.0157
      - days: Sun-Sat
        hours: 8-21
        price: 0.0860
      - days: Sun-Sat
        hours: 22-23
        price: 0.0157

Same code can be added to other tariffs. Once it reaches final version.

andig commented 2 days ago

@bartashevich thank you for this PR. Unfortunately, we can't implement it this way: your PR largely duplicates the code that we already have in the fixed tariff. Instead, we need to reuse as much as possible, much more if we want to add this to other tariffs.

Also: your example of adding prices for zones is confusing. The price already comes from ENTSO-E, so why would you want to manually define it?

bartashevich commented 2 days ago

@bartashevich thank you for this PR. Unfortunately, we can't implement it this way: your PR largely duplicates the code that we already have in the fixed tariff. Instead, we need to reuse as much as possible, much more if we want to add this to other tariffs.

Also: your example of adding prices for zones is confusing. The price already comes from ENTSO-E, so why would you want to manually define it?

Fixed zone pricing seems a bit more complex and not easy to adapt for dynamic pricing.

In terms of ENTSO-E, price come in raw and we have a lot of custom taxes to apply. And on top of that, we need to apply zoned pricing.

I wasn't expecting for this PR to be merged right away. I'm happy to keep on working on this until we reach ideal solution.

andig commented 2 days ago

In terms of ENTSO-E, price come in raw and we have a lot of custom taxes to apply. And on top of that, we need to apply zoned pricing.

It still seems your example is not using the Entso price add all?

andig commented 2 days ago

Also note https://github.com/evcc-io/evcc/pull/17414 which could be used instead of zones?

bartashevich commented 2 days ago

Also note #17414 which could be used instead of zones?

Can you provide me an example where I can apply both:

bartashevich commented 2 days ago

@andig, What about reusing code from fixed zones by implementing sum of 2 tariffs?

If dynamic tariff have zones, it would create fixed tariff entity and then it would sum to current dynamic tariff.

Do you think that would work?

andig commented 2 days ago

Can you provide me an example where I can apply both:

How about, instead of adding zones:

charges := 0.0860
if hr := ts.Hour(); hr < 8 || hr >= 23 {
    charges = 0.0157
}
(price + 0.004 + 0.0028930 + 0.010) * 1.16 + 0.005 + charges

/cc @VolkerK62 @naltatis bzgl. Doku

bartashevich commented 2 days ago

dismissed in favor of https://github.com/evcc-io/evcc/pull/17414