evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Grünstromindex caching issue

Open martin5233 opened this issue 3 weeks ago • 8 comments

Describe the bug

I set up a plan to charge my car a few days ahead, i.e. I created the plan on Dec. 6th for Dec 9th, 8am. No actual plan was displayed, instead the UI said something like "unknown CO2". After investigating a bit, I found that seemingly the data retrieved from Grünstromindex is cached multiple days without updating it, before the cache expires. If the time span from creation to target date crosses the end of the cache validity, evcc will not start to charge at all.

Steps to reproduce

  1. Enable usage of Grünstromindex (no token, docs say its optional)
  2. Check log file for statement "using cache: grünstromindex...", which contains the cached period
  3. Create a charge plan for the morning after the end of the caching period.

evcc does not show any planned period for charging until the cache expires. Note that I restart my docker container with evcc every night for backup reasons, I'm not sure, if this is relevant.

Configuration details

# open evcc at http://evcc.local:7070
network:
  schema: http
  host: evcc.local # .local suffix announces the hostname on MDNS
  port: 7070

log: debug

# unique installation id
plant: *** removed ***
interval: 10s # control cycle interval
telemetry: true
sponsortoken: *** removed ***

mqtt:
  broker: cube:1883
  clientid: evcc

meters:
- name: grid
  type: custom
  power:
    source: modbus
    id: 1
    uri: 192.168.1.43:502
    register:
      address: 40073
      type: holding
      decode: int32s
- name: pv
  type: custom
  power:
    source: modbus
    id: 1
    uri: 192.168.1.43:502
    register:
      address: 40067
      type: holding
      decode: int32s
- name: battery
  type: custom
  power:
    source: calc
    mul:
      scale: -1
      source: modbus
      id: 1
      uri: 192.168.1.43:502
      register:
        address: 40069
        type: holding
        decode: int32s
  soc:
    source: modbus
    id: 1
    uri: 192.168.1.43:502
    register:
      address: 40082
      type: holding
      decode: uint16
  energy:
    source: calc
    mul:
      scale: 0.0825
      source: modbus
      id: 1
      uri: 192.168.1.43:502
      register:
        address: 40082
        type: holding
        decode: uint16

vehicles:
- type: template
  template: polestar
  user: *** removed ***
  password: *** removed ***
  title: Polly
  icon: car
  capacity: 79
  phases: 3
  mode: pv
  name: polestar

chargers:
- name: wallbox
  type: template
  template: tinkerforge-warp3-smart
  host: cube
  topic: warp3

site:
  title: Mein Zuhause
  meters:
    grid: grid
    pv:
    - pv
    battery:
    - battery
  residualpower: 100

loadpoints:
  - title: Garage
    charger: wallbox
    vehicle: polestar
    enable:
      threshold: -3000
      delay: 3m
    disable:
      threshold: 0
      delay: 3m

tariffs:
  currency: EUR
  grid:
    type: fixed
    price: 0.3866  # EUR/kWh
  feedin:
    type: fixed
    price: 0.0811 # EUR/kWh
  co2:
    type: template
    template: grünstromindex
    zip: *** removed ***
  solar:
    - type: template
      template: solcast
      site: *** removed ***
      token: *** removed ***
      from: "9"
      to: "14"
      interval: 3h

Log details

evcc  | [tariff] DEBUG 2025/12/01 01:05:41 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-01 01:00:00 +0100 CET, end: 2025-12-05 00:00:00 +0100 CET)
evcc  | [tariff] DEBUG 2025/12/02 01:05:41 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-01 01:00:00 +0100 CET, end: 2025-12-05 00:00:00 +0100 CET)
evcc  | [tariff] DEBUG 2025/12/03 01:06:24 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-01 01:00:00 +0100 CET, end: 2025-12-05 00:00:00 +0100 CET)
evcc  | [site  ] WARN 2025/12/04 00:00:37 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:38 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:38 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:48 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:58 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 01:04:18 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 01:04:28 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 01:04:38 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 01:04:48 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [tariff] DEBUG 2025/12/05 01:05:59 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-05 01:00:00 +0100 CET, end: 2025-12-09 00:00:00 +0100 CET)
evcc  | [tariff] DEBUG 2025/12/06 01:05:57 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-05 01:00:00 +0100 CET, end: 2025-12-09 00:00:00 +0100 CET)
evcc  | [tariff] DEBUG 2025/12/07 01:05:57 using cache: grünstromindex-be568b5c7ed027ff5a40a885b1c9bd1da87146c7dd4d9dc4bc8c077d49236334 (start: 2025-12-05 01:00:00 +0100 CET, end: 2025-12-09 00:00:00 +0100 CET)

What type of operating system or environment does evcc run on?

Docker container

External automation

  • [x] I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.

Nightly build

  • [x] I have verified that the issue is reproducible with the latest nightly build

Version

v0.210.2

martin5233 avatar Dec 07 '25 13:12 martin5233

No actual plan was displayed, instead the UI said something like "unknown CO2".

Pls add screenshot and output of /api/state

andig avatar Dec 07 '25 16:12 andig

This is confusing- where do these multiple requests within a second come from? Can you add --log-headers and show the full gsi trace log?

evcc  | [site  ] WARN 2025/12/04 00:00:37 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:38 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)
evcc  | [site  ] WARN 2025/12/04 00:00:38 planner: cannot create tariff type 'grünstromindex': unexpected status: 429 (Too Many Requests)

andig avatar Dec 07 '25 16:12 andig

the time span from creation to target date crosses the end of the cache validity, evcc will not start to charge at all.

Are you sure that really happens? To my experience, rvcc falls back to late charging when GSI is unavailable.

mfuchs1984 avatar Dec 07 '25 17:12 mfuchs1984

Thank you for quick responses:

  • I have attached a screenshot as well as the reult of /api/state Image
  • I have tried to increase the logging, but after a restart of the docker container, the output contained no trace statements. I tried two different approaches: levels:<lf> gsi: trace and levels:<lf> tariff: trace but none of them generated any trace statements. I'm not sure, what I#m doing wrong here.
  • I don't know where to add --log-headers, when running evcc in docker.

And to answer your question: Probably evcc will fall back to loading late, but that's not the goal of using Grünstromindex. Please also note, that the Error 429 repeated for one hour, I had deleted a lot of them from the logs, as they obscured the rest (which I should have mentioned from the start ;-)

state.json

martin5233 avatar Dec 07 '25 17:12 martin5233

but none of them generated any trace statements. I'm not sure, what I#m doing wrong here.

Probably all cached data.

Probably evcc will fall back to loading late, but that's not the goal of using Grünstromindex.

It's the current behavior it case of limited knowledge. We just assume better rates afterwards. It's a guess.

Please also note, that the Error 429 repeated for one hour, I had deleted a lot of them from the logs, as they obscured the rest (which I should have mentioned from the start ;-)

If you're able to trigger that please let me know how. It should not do multiple requests.

andig avatar Dec 07 '25 17:12 andig

I have no idea, how to trigger the Error 429, I simply observed them in the log file. They came shortly after restarting the docker container a couple of nights ago. Do I need a token to use Grünstromindex? May this be the reason?

martin5233 avatar Dec 07 '25 17:12 martin5233

I have no idea, how to trigger the Error 429, I simply observed them in the log file. They came shortly after restarting the docker container a couple of nights ago. Do I need a token to use Grünstromindex? May this be the reason?

I have these 429 errors too since some days: Image

Restarting the docker container has no effect.

DanielGlaas avatar Dec 12 '25 17:12 DanielGlaas

Plesse note:

This API is known to be unreliable, see my issue #25512.

DanielGlaas avatar Dec 12 '25 17:12 DanielGlaas

With nightly, we‘ve added a header that indicates if data was served from cache. When logging headers this should help diagnosis.

andig avatar Dec 25 '25 09:12 andig