evcc icon indicating copy to clipboard operation
evcc copied to clipboard

pvnode v2 update interval

Open Dalton0190 opened this issue 4 months ago • 2 comments

Description

It seems that pvnode v2 forecast does not update at the configured interval forecast in evcc was way off compared to pvnode dashboard, after evcc restart it was ok again in pvnode dashboard the usage count only increments when i restart evcc did not find anything about pvnode in the logfile

Steps to Reproduce

goto configuration - solar forecast set interval normally to 3600 seconds, for test now its 5 seconds

Version

v0.312.1

System

linux/amd64, CEST +02:00

Configuration (YAML)

no yaml configuration

Configuration (UI)

{
  "charger": [
    {"id":5,"name":"db:5","type":"template","config":{"template":"ocpp-goe","connector":"1","connecttimeout":"5m","meterinterval":"10s","stationid":"***"},"deviceProduct":"Fronius Wattpilot (OCPP)"}
  ],
  "experimental": true,
  "influx": {"database":"","insecure":false,"org":"","password":"","token":"","url":"","user":""},
  "interval": 20,
  "loadpoints": [
    {"id":6,"name":"db:6","batteryBoostLimit":100,"charger":"db:5","defaultMode":"","limitEnergy":0,"limitSoc":0,"maxCurrent":16,"minCurrent":6,"minSoc":0,"phasesConfigured":0,"planEnergy":0,"planPrecondition":0,"planStrategy":{"continuous":false,"precondition":0},"planTime":"0001-01-01T00:00:00Z","priority":10,"smartCostLimit":-0.11,"smartFeedInPriorityLimit":null,"soc":{"estimate":true,"poll":{"interval":3600000000000,"mode":"charging"}},"thresholds":{"disable":{"delay":180000000000,"threshold":0},"enable":{"delay":60000000000,"threshold":0}},"title":"Carport","ui":{"maxTemp":0,"minTemp":0},"vehicle":"db:14"}
  ],
  "meter": [
    {"id":41,"name":"db:41","type":"template","config":{"template":"homeassistant","currentL1":"sensor.smart_meter_63a_stromstarke_l1","currentL2":"sensor.smart_meter_63a_stromstarke_l2","currentL3":"sensor.smart_meter_63a_stromstarke_l3","energy":"sensor.smart_meter_63a_wirkenergie_minus","insecure":false,"maxacpower":"0","power":"sensor.warmepumpe_leistung_invertiert","uri":"***","usage":"charge","voltageL1":"sensor.smart_meter_63a_spannung_phase_1","voltageL2":"sensor.smart_meter_63a_spannung_phase_2","voltageL3":"sensor.smart_meter_63a_spannung_phase_3"},"deviceIcon":"airpurifier","deviceProduct":"Home Assistant","deviceTitle":"Wärmepumpe"},
    {"id":10,"name":"db:10","type":"template","config":{"template":"fronius-solarapi-v1","batteryconfiguri":"/config","host":"192.168.2.66","usage":"pv","user":"***"},"deviceProduct":"Fronius Solar API V1","deviceTitle":"Dach"},
    {"id":13,"name":"db:13","type":"template","config":{"template":"fronius-ohmpilot","host":"froniusgen24.local","key":"0","usage":"aux"},"deviceIcon":"smartconsumer","deviceProduct":"Fronius Ohmpilot","deviceTitle":"Ohmpilot"},
    {"id":9,"name":"db:9","type":"template","config":{"id":"200","template":"fronius-gen24","host":"froniusgen24.local","maxacpower":"0","maxchargerate":"100","port":"502","usage":"pv"},"deviceProduct":"Fronius Symo GEN24 Plus","deviceTitle":"Fassade"},
    {"id":8,"name":"db:8","type":"template","config":{"id":"200","template":"fronius-gen24","host":"froniusgen24.local","maxacpower":"0","maxchargerate":"100","port":"502","usage":"grid"},"deviceProduct":"Fronius Symo GEN24 Plus"},
    {"id":11,"name":"db:11","type":"template","config":{"id":"200","template":"fronius-gen24","capacity":19.3,"host":"froniusgen24.local","maxacpower":"0","maxchargerate":"100","minsoc":10,"port":"502","usage":"battery"},"deviceProduct":"Fronius Symo GEN24 Plus","deviceTitle":"BYD HVM"}
  ],
  "mqtt": {"broker":"","caCert":"","clientCert":"","clientID":"","clientKey":"","insecure":false,"password":"","topic":"evcc","user":""},
  "residualPower": 100,
  "shm": {"deviceId":"","deviceSerial":"","vendorId":""},
  "site": {"aux":["db:13"],"battery":["db:11"],"consumer":["db:41"],"ext":null,"grid":"db:8","pv":["db:9","db:10"],"title":"Maybaums"},
  "tariff": [
    {"id":42,"name":"db:42","type":"template","config":{"template":"pvnode-v2","apikey":"***","forecast_days":5,"interval":"","site_id":"site_543a8s5weyp9dd938zi4"},"deviceProduct":"pvnode V2 API","deviceTitle":"PV Prognose"},
    {"id":15,"name":"db:15","type":"template","config":{"template":"epex-predictor","average":false,"charges":0.0144,"region":"AT","uri":"***"},"deviceProduct":"EPEX Predictor Predicted EPEX spot prices"},
    {"id":16,"name":"db:16","type":"template","config":{"template":"electricitymaps-free","token":"***","zone":"AT"},"deviceProduct":"Electricity Maps Free API"}
  ],
  "tariffRefs": {"co2":"db:16","feedIn":"","grid":"db:15","planner":"","solar":["db:42"],"temperature":""},
  "vehicle": [
    {"id":14,"name":"db:14","type":"template","config":{"template":"tesla","accessToken":"***","cache":"15m","capacity":75,"clientId":"8f1c5511-0897-4f02-aa51-28ade5380a57","commandProxy":"https://api.myteslamate.com","icon":"car","refreshToken":"***","title":"Tesla","vin":"***"},"deviceProduct":"Tesla"}
  ]
}

Logs

[lp-1  ] DEBUG 2026/07/26 08:00:35 charger status: B
[lp-1  ] DEBUG 2026/07/26 08:00:35 !! plan: plan time zero
[lp-1  ] DEBUG 2026/07/26 08:00:35 pv charge current: 0A = 0A + -0.555A (128W @ 1p)
[site  ] DEBUG 2026/07/26 08:00:35 solar forecast: produced 2.428kWh, forecasted 1.025kWh, scale 2.369
[site  ] DEBUG 2026/07/26 08:00:55 ----
[lp-1  ] DEBUG 2026/07/26 08:00:55 charge power: 0W
[lp-1  ] DEBUG 2026/07/26 08:00:55 charge currents: [0 0 0]A
[site  ] DEBUG 2026/07/26 08:00:55 grid power: -31W
[site  ] DEBUG 2026/07/26 08:00:55 consumer 1 power: 20W
[site  ] DEBUG 2026/07/26 08:00:55 grid powers: [891 -248 -675]W
[site  ] DEBUG 2026/07/26 08:00:55 pv 2 power: 1472W
[site  ] DEBUG 2026/07/26 08:00:55 battery 1 power: -1156W
[site  ] DEBUG 2026/07/26 08:00:55 pv 1 power: 2038W
[site  ] DEBUG 2026/07/26 08:00:55 grid currents: [4.26 -2.49 -2.95]A
[site  ] DEBUG 2026/07/26 08:00:55 battery 1 soc: 35%
[site  ] DEBUG 2026/07/26 08:00:55 aux 1 power: 0W
[site  ] DEBUG 2026/07/26 08:00:55 pv power: 3510W
[site  ] DEBUG 2026/07/26 08:00:55 battery has priority at soc 35% (< 100%)
[site  ] DEBUG 2026/07/26 08:00:55 site power: 69W
[lp-1  ] DEBUG 2026/07/26 08:00:55 charge voltages: [231 227 231]V
[lp-1  ] DEBUG 2026/07/26 08:00:55 charge total import: 4811.786kWh
[lp-1  ] DEBUG 2026/07/26 08:00:55 charger status: B
[lp-1  ] DEBUG 2026/07/26 08:00:55 !! plan: plan time zero
[lp-1  ] DEBUG 2026/07/26 08:00:55 pv charge current: 0A = 0A + -0.298A (69W @ 1p)
[site  ] DEBUG 2026/07/26 08:00:55 solar forecast: produced 2.428kWh, forecasted 1.025kWh, scale 2.369

Dalton0190 avatar Jul 26 '26 06:07 Dalton0190

Analysis

Traced this in code — tariff/proxy_cache.go (used for tariffs with the cacheable feature, which pvnode-v2 has via templates/definition/tariff/pvnode-v2.yaml).

cachingProxy.Rates() only creates the actual underlying tariff instance (NewFromConfig) when p.tariff == nil and the persisted cache doesn't already cover at least the next 24h (cacheGet(for24hrs()), proxy_cache.go:94-100). Only once the real instance is created does its background refresh loop start — that loop is what actually honors the configured interval (tariff/tariff.go:79-92, t.run(...)).

With forecast_days: 5 (as in your config), a previously persisted forecast can cover well beyond 24h, so on startup Rates() keeps serving the stale persisted cache and never instantiates the real tariff at all — meaning no HTTP call is made, no log line is produced, and the configured interval (even 5s) has no effect — until the cached horizon eventually shrinks to under 24h. This matches all three symptoms: forecast increasingly diverges from reality, no pvnode entries in the log, and the pvnode dashboard's usage counter only increments on restart (restart just happens to coincide with when the stale-cache window finally expires).

So this isn't a pvnode-v2 template issue but a general defect in the cacheable caching proxy: it ignores the provider's configured interval for refresh timing and only re-fetches based on remaining forecast horizon, which can silently stall updates for days when forecast_days > 1.

This affects any solar/tariff template using features: ["cacheable"] (solcast, forecast-solar, voltcast, groupe-e, gruenstromindex, energypriceforecast-co2, electricitymaps), not just pvnode-v2.

Fixing this correctly needs some design thought (balancing respecting interval against the vendor rate-limit protection the cache was built for), so I'm not opening a PR for it — flagging as bug for a maintainer to weigh in on the intended refresh behavior.

🤖 Generated with Claude Code

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

The question is how we want this to behave: cache ensures that restarting evcc does not consume API requests. Interval on the other hand refreshes data. What should happen if both are present? In case of pvnode (where the default with very limited forecast_days is 1d), we might just gate the cache on forecast_days == 1 and otherwise disable? Or maybe we should make the cacheable feature just kick in if last request is within interval?

andig avatar Jul 26 '26 09:07 andig