fix(pvforecast): normalize Forecast.Solar power before resampling (#1487)

Forecast.Solar supplies instantaneous power with irregular sunrise/sunset timestamps. GENETIC interprets stored values as interval averages and infers cadence from the shortest gap, so these samples create artificial coverage gaps. The prediction list API also averages away the sunset zero before interpolating, producing positive nighttime PV.

Integrate each roof plane's piecewise-linear power curve into UTC-contiguous 15-minute interval-average W before summing planes. Both hourly and quarter-hour GENETIC slots then consume the same normalized data as the prediction API, with exactly one downstream W-to-Wh conversion. Explicit sunrise/sunset zero boundaries establish the adjacent night within each forecast day. Daylight gaps longer than an hour, invalid power, absent planes and unavailable forecast days remain missing; the strict GENETIC coverage check stays in place.

Refreshes replace the current forecast and remove stale tails. Because cadence detection also sees historical records, the first refresh clears legacy forecasts containing non-aligned timestamps, including their history. Later refreshes retain normalized history. This upgrade behavior is documented.

Forecast validation errors now identify the first invalid interval and the number of invalid slots.
This commit is contained in:
Normann
2026-11-07 19:46:58 +01:00
committed by GitHub
parent 651301f9e6
commit b33953d445
5 changed files with 359 additions and 26 deletions
+11 -1
View File
@@ -1014,7 +1014,17 @@ The prediction keys for the PV forecast data are:
The `PVForecastForecastSolar` provider retrieves PV power forecasts from the free
[Forecast.Solar](https://forecast.solar) API. No API key is required for the public endpoint; an
optional key raises the rate limit. The location is taken from `general.latitude`/`longitude` and
the system geometry from the configured `planes` (one request per plane, summed per timestamp).
the system geometry from the configured `planes` (one request per plane).
The provider integrates Forecast.Solar's instantaneous power samples into 15-minute
interval-average W before summing the planes. Sunrise and sunset retain their actual
timestamps during integration; explicit zero boundaries establish nighttime zeros within
each forecast day. Missing daylight samples, invalid values, and unavailable days remain
missing. GENETIC converts the averages to Wh for its configured 15-minute or hourly slots.
Refreshing the provider replaces older samples and removes unavailable forecast tails.
On the first refresh after upgrading, legacy forecasts with non-aligned timestamps are
cleared, including history, so they cannot distort cadence detection. Later refreshes
retain the normalized history.
```python
{