Tariff caching causes stale data on evcc restart for Amber
Describe the bug
Since https://github.com/evcc-io/evcc/pull/22446 it appears that the Amber tariff isn't invoked at all if there's >24 hours of data available in the database.
That's an issue, as Amber returns a few days worth of data, and this is subject to wild differences in pricing over this time.
The API's rate limiting is all based around people querying it often due to these changes. Can we have a way for a tariff to opt-out of caching (while keeping it for those APIs that have rate limiting issues)?
Steps to reproduce
- Start evcc with amber tariff and clean DB, observe it working correctly, updating pricing once a minute.
- Stop evcc
- Start evcc again, observe that the logs say using cache and stale data is used for a day
Configuration details
tariffs:
currency: AUD
grid:
type: amber
...
Log details
working:
[amber ] TRACE 2025/08/10 15:55:38 [{"type":"CurrentInterval","date":"2025-08-10","duration":5,"startTime":"2025-08-10T05:55:01Z","endTime":"2025-08-10T06:00:00Z"
... etc
not working:
[tariff] DEBUG 2025/08/10 15:44:30 using cache: amber-ff00bd16517e1ad0a4f6ac4d412bf834901f75178487765151f7288b289aa4b8 (start: 2025-08-10 15:00:00 +1000 AEST, end: 2025-08-12 04:00:00 +1000 AEST)
What type of operating system or environment does evcc run on?
Linux
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
master
The road to hell is paved with good intentions. Seems this kills the "current hour/ current price" hack from https://github.com/evcc-io/evcc/issues/22521.
The purpose of the caching is to avoid depleting scarce request quotas. Seems we should not be doing this for all tariffs. That leaves the question:
- Is Amber specifically immune to repeated requests? Then we could just exempt it from caching.
- Should we generally make caching opt-in?
- Is a specific opt-out sufficient?
- What's the api for either case?
Let's concentrate on the general direction first.
/cc @terrorobe @naltatis
Should we generally make caching opt-in?
I think this would be a good idea. Currently we also do caching for static prices (no comm). That's not needed.
Currently we also do caching for static prices (no comm).
That was not intentional at least :/
If we want opt-in:
- which tariffs require that?
- how do we configure it?
- which config do we need?
Technically, I'd prefer extending tariff-base to contain tariff-cache which could also be embedded on it's own. Do we want to make tariff-cache more complicated than just cache: true? In which way?
Not sure if I have the complete overview but the rate-limit issue is primarily (only?) relevant for solar forecast tariffs. I'd suggest to activate caching for them all once. Going forward we can/should decide case by case.
Could we exclude all custom type solar forecast tariffs from caching? I think this type is used primarily for own implementations. Caching leads to adverse behaviour if forecast data for more than 24 hours is provided.
In my use case, I use a custom backend that provides solar forecast data. Caching is not needed there.
Test would be great :)