Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tariffs: make timestamp available for formulas #17414

Merged
merged 11 commits into from
Nov 29, 2024
Merged

Conversation

andig
Copy link
Member

@andig andig commented Nov 23, 2024

Follow-up to #17002, fix #12371.

This PR adds a ts variable of type time.Time that contains the start of the current slot. The timestamp is in local timezone to allow immediate use of ts.Hour() for comparisons.

Could be nicer with traefik/yaegi#1542.

@andig andig added needs documentation Triggers issue creation in evcc-io/docs tariffs Specific tariff support labels Nov 23, 2024
@andig andig requested a review from naltatis November 23, 2024 17:26
tariff/embed.go Outdated Show resolved Hide resolved
@bartashevich
Copy link

@andig , testing this branch and got following error:

[main  ] ERROR 2024/11/24 18:09:37 creating tariff grid failed: cannot create tariff type 'entsoe': _.go:12:2: expected declaration, found charges

Configs:

tariffs:
  grid:
    type: entsoe
    domain: BZN|PT
    securitytoken: xxxx
    charges: 0
    tax: 0
    formula: (price + 0.004 + 0.0028930 + 0.010)*(1 + 0.16) + 0.005

If I remove formula, it works.

@bartashevich
Copy link

I've fixed commit that introduced described error, keeping everything else the same and I got it working.

Current issue is that ts.Hour() always returns 23.

I've used following formula:

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

For debug purpose I've added float64(ts.Hour()) to formula and result is this:
image

@andig
Copy link
Member Author

andig commented Nov 24, 2024

@bartashevich
Copy link

See https://github.com/evcc-io/evcc/pull/17414/files#diff-34973a15082498aae9145173918172786bbd9f17991a8cb38f8009a57339d666R143 and make sure to use the same for ENTSO-E!

Oh I see, since you've changed in tariff.go I imagined it would be global some how. Sorry, not familiar at all with this framework.

@bartashevich
Copy link

What do you need to merge this?

@andig andig merged commit b52d08a into master Nov 29, 2024
6 checks passed
@andig andig deleted the feat/tariff-timestamps branch November 29, 2024 09:15
jonilala796 pushed a commit to jonilala796/evcc that referenced this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation Triggers issue creation in evcc-io/docs tariffs Specific tariff support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tariffs: add time-dependent charges (peak and off-peak)
3 participants