evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Dynamic electricity tariff via API for CKW

Open nakor opened this issue 10 months ago • 10 comments

Is your feature request related to a problem? Please describe. This is just a feature request to integrate the CKW API for dynamic electricity tariffs

Describe the solution you'd like I'd like to have a ready to go template for the ckw dynamic electricity tariffs API (like Tibber)

Describe alternatives you've considered It's possible to integrate the ckw API with the custom plugin. But it took me quite some time to come up with a working solution. So I'd like to make it easier for other Users. My working 'custom plugin' template is added below.

Additional context Technical Documentation from CKW (only in German): https://www.ckw.ch/energie/strom/dynamischer-tarif-fuer-privatkunden-und-unternehmen/dynamischer-tarif-technische-voraussetzungen

Below my workaround tariffs configuration with the custom plugin: The request does replace the start_timestamp in the uri with a timestamp from yesterday and the end_timestamp with a date 3 days in the future. (I'm not sure if that makes sense but it works for now.) It is important to define start and end timestamp in the request because without them the api just returns the values for the actual day. It is also important to define the timestamps in the UTC format (with the 'Z' at the end) because if not defined the API returns values in local (CET/CEST) time. The jq filter transforms the reply to the readable format for EVCC and adds the missing Seconds in the timestamps.

currency: CHF

grid:
  type: custom
  interval: 15m
  forecast:
    source: http
    uri: "https://e-ckw-public-data.de-c1.eu1.cloudhub.io/api/v1/netzinformationen/energie/dynamische-preise?tariff_type=integrated&tariff_name=home_dynamic&start_timestamp={{ (now.AddDate 0 0 -1).Format \"2006-01-02T00:00:00Z\" }}&end_timestamp={{ (now.AddDate 0 0 3).Format \"2006-01-02T00:00:00Z\" }}"
    timeout: 15s
    jq: |
      .prices | map({
        "start": (.start_timestamp | sub("Z$"; ":00Z")),
        "end": (.end_timestamp | sub("Z$"; ":00Z")),
        "value": (.integrated[0].value)
      }) | tostring

nakor avatar Jan 09 '26 19:01 nakor

Nice! Do you want to open a PR?

andig avatar Jan 10 '26 09:01 andig

@nakor exactly what i was looking for, thank you!

RRonGit avatar Jan 11 '26 18:01 RRonGit

Nice! Do you want to open a PR?

I just posted this Issue because you request for this in the official Documentation. #dynamic-electricity-tariff-via-api And because it might help other users.

If you think it makes sense to create a PR I support this. But I need some guidance how to proceed. I'm not a developer and wont be able to provide code. But I can support with additional information about the API what I noticed so far, or with testing...

nakor avatar Jan 11 '26 19:01 nakor

These are the other tariffs as examples: https://github.com/evcc-io/evcc/tree/master/templates/definition/tariff

andig avatar Jan 20 '26 08:01 andig

I think all the swiss providers have decided to agree on a common format for dynamic tariffs (although I saw few differences, for instance in the time format). That should simplify new implementations. Groupe E and EKZ are already integrated

for Groupe E I' am testing currently an updated version (V2 of Groupe E -> moved to the new swiss standard) : https://github.com/evcc-io/evcc/issues/26898#issuecomment-3800975579

for CWK : I proposed this PR https://github.com/evcc-io/evcc/pull/27051

if it is accepted you can then test it with the nightly build you can add to your evcc.yaml

tariffs: currency: CHF grid: type: template template: ckw tariff: home_dynamic

I saw VAT is not included in the tariffs so maybe you want to add tax: 0.081

@andig : I don't why PR failed in the checks. Maybe you can check?

spasdev avatar Jan 27 '26 13:01 spasdev

@andig : it was an encoding issue, now it passed all the test.

spasdev avatar Jan 27 '26 14:01 spasdev

I saw VAT is not included in the tariffs so maybe you want to add

@spasdev FYI, I have opened a PR exactly for this for EKZ, because they also do not include VAT in their API. https://github.com/evcc-io/evcc/pull/27058

uwolfer avatar Jan 27 '26 20:01 uwolfer

I saw VAT is not included in the tariffs so maybe you want to add

@spasdev FYI, I have opened a PR exactly for this for EKZ, because they also do not include VAT in their API. #27058

ok, thank you. I added VAT as well to CKW PR.

spasdev avatar Jan 29 '26 07:01 spasdev

@nakor : it was released with 0.300.7 if ok I think we can close this thread

spasdev avatar Feb 03 '26 09:02 spasdev

Thank you all. I haven‘t tested the new Solution but will do when i have time. But it looks like you did a great job. So we can close this thread.

nakor avatar Feb 03 '26 10:02 nakor