evcc icon indicating copy to clipboard operation
evcc copied to clipboard

combined tariff: rates with same timestamp not summed when sources cover different time ranges

Open 1va13n7in opened this issue 4 months ago • 2 comments

Describe the bug

combined.Rates() uses lo.PartitionBy which only groups consecutive elements with the same key When multiple solar tariffs cover overlapping but different time ranges, rates with identical timestamps are not next to each other after concatenation Result: values are not summed, they appear as separate entries Reproducible with 3 solar sources (2x Solcast + Forecast.Solar) Fix: sort before partitioning (one line)

Steps to reproduce

  1. Configure multiple solar tariff sources covering different time ranges: tariffs: solar: - type: custom forecast: ... # e.g. Solcast today - type: custom forecast: ... # e.g. Solcast tomorrow - type: custom forecast: ... # e.g. Forecast.Solar

  2. Run: evcc tariff solar

  3. Observe that some timeslots appear multiple times instead of being summed. Example output (end of list): 2026-07-24 00:45:00 2026-07-25 01:00:00 0.000 2026-07-23 16:00:00 2026-07-23 16:15:00 874.000 2026-07-23 16:15:00 2026-07-23 16:30:00 837.250

    The last two entries should have been added to the Solcast values for the same slots, not listed separately at the end.

Expected behaviour: All rates with the same start timestamp should be summed into a single entry, regardless of source order or time range coverage.

Configuration details

kubectl -n evcc exec deploy/evcc -- evcc dump --cfg
[main  ] INFO 2026/07/23 17:35:08 using config file: /etc/evcc.yaml
[main  ] INFO 2026/07/23 17:35:08 using sqlite database: /root/.evcc/evcc.db?_pragma=busy_timeout(5000)&_pragma=foreign_keys(1)&_pragma=auto_vacuum(INCREMENTAL)
[eebus ] INFO 2026/07/23 17:35:18 Local SKI: d5169309c37270892efc2fff7809d63f62cb8414
[ha-meter] WARN 2026/07/23 17:35:18 using deprecated 'home' parameter 'HomeAssistant', please use 'uri' instead
[ha-meter] WARN 2026/07/23 17:35:18 using deprecated 'home' parameter 'HomeAssistant', please use 'uri' instead
[ha-meter] WARN 2026/07/23 17:35:18 using deprecated 'home' parameter 'HomeAssistant', please use 'uri' instead
[main  ] INFO 2026/07/23 17:35:18 circuit victron has no meter and no loadpoint assigned

Version: `0.311.1`

Log details

2. Run: evcc tariff solar

3. Observe that some timeslots appear multiple times instead of being summed.
   Example output (end of list):
   2026-07-24 00:45:00    2026-07-25 01:00:00    0.000
   2026-07-23 16:00:00    2026-07-23 16:15:00    874.000
   2026-07-23 16:15:00    2026-07-23 16:30:00    837.250

   The last two entries should have been added to the Solcast values
   for the same slots, not listed separately at the end.

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

evcc version 0.311.1

1va13n7in avatar Jul 23 '26 15:07 1va13n7in

Confirmed. combined.Rates() in tariff/combined.go concatenates rates from all configured tariff sources, then calls lo.PartitionBy on the unsorted slice to group by Start time. lo.PartitionBy only groups consecutive elements with equal keys, so when sources cover different (non-contiguous) time ranges, rates sharing a Start timestamp aren't adjacent after concatenation and end up as separate entries instead of being summed, exactly as described.

Fix: sort the combined rates by Start before partitioning (api.Rates already has a Sort() method for this).

Opened a draft fix: #32094 (includes a regression test reproducing the disjoint-source scenario).

🤖 Generated with Claude Code

github-actions[bot] avatar Jul 23 '26 15:07 github-actions[bot]

Summing over half-overlapping time series is an assumption. Why is this needed in the first place?

andig avatar Jul 23 '26 16:07 andig