Feature: Automated Solar Clipping Mitigation (using native clear-sky models) - #4086
Feature: Automated Solar Clipping Mitigation (using native clear-sky models)#4086rholligan wants to merge 168 commits into
Conversation
… for flexible clearsky overlay
… to match legacy mockup
…o enable historical tracking
|
Claude here, on chalfontchubby's behalf. Closing #4036 and continuing here sounds right — this branch is on current main, mergeable, and it takes on the Three things that might save you some time, offered as findings rather than as anything you need to adopt. #4871 changes the code next door. It fixes an operator-precedence bug that left the cloud divergence model inert for every array except pv10 — so the central PV and all three load series were never modulated at all. It also now makes the subtract respect the A local clear-sky fallback, if you want one. All three of your sources are external — the Solcast Three findings from a prototype. We built a plan-side version before you picked this up, to understand the problem rather than to compete with this — it is on
Supporting data from that issue, simulating a buffer against 8 days of 1-minute history:
Which is the argument for clear-sky sizing over a percentile: Solcast's pv90 for that array sat about 18% below its measured clear-sky ceiling, so percentile-derived sizing undershoots. Your default looks right. Shout if any of it is useful. Otherwise we will stay out of the way and keep an eye on how it is going. Written by Claude, on chalfontchubby's behalf. |
…rge logic" This reverts commit 0702bf5.
The previous commit mistakenly unpacked a 3-tuple from window_arrays, where the 3rd element was the raw Python window list rather than the intended export_flags ctypes array. This caused a TypeError when assigning to pk_job.export_flags (which expects LP_c_int), breaking parallel batch optimization and failing test_kernel_parity. This commit updates window_arrays to properly generate and return the export_flags ctypes array as part of a 4-tuple.
Mirrors the changes made in the C++ prediction engine port, specifically the addition of clipping_cost_weight penalty and dynamically calculating discharge minimum.
Uses github.event.pull_request.head.repo.full_name to ensure the workflow can correctly check out the PR branch when running from a forked repository.
Fixes a compilation error where unused-but-set-variable triggered a failure due to -Werror during cross-compilation.
Attempting to resolve 403 on push from fork by utilizing lite-action or failing that, capturing the binaries as artifacts.
Since GitHub Actions lacks permissions to push from the parent repo to this fork, manually checking in the binaries downloaded from the latest CI artifact.
|
Thanks @chalfontchubby, these insights are really helpful! I'm going to have a go at implementing the plan-side buffer and episode scoping from your branch. Applying the ceiling directly to the search limits instead of mutating the simulation is definitely a cleaner approach. Would be great to have your eyes on that, and give it a test run if possible. @springfall2008 - what are your thoughts on adding the clearsky calcs nateively to predbat? Also, just a quick check on how you'd like to proceed with this PR. It's now passing pre-commit CI, so let me know if you are happy reviewing it as-is, or if you'd still prefer I split it out into the 3 smaller PRs proposed above. |
…tly abut When an anti-clipping export window ended on the exact same minute that a candidate charge window started (e.g., dend == start), the intersection condition (dend >= start) evaluated to True but the resulting split left the window completely unchanged. This caused the unclipped window to be appended back to the candidate list and flagged for another pass, creating a permanent infinite loop that hung the Python thread and eventually triggered a LoadMLComponent timeout. This commit corrects the intersection to use dend > start in both Python and C++ prediction kernels to prevent perfectly abutting windows from looping.
|
The cloud model fix is merged. You might want to pull that in. |
76ddc61 to
2356720
Compare
2356720 to
09bdf4b
Compare
Introduction:
This PR introduces a native clipping buffer to Predbat. It prevents solar energy loss on high-generation days by creating dynamic headroom in the battery SoC, specifically targeting periods where PV generation is forecast to exceed inverter AC capacity or DNO export limits.
This implementation integrates with the existing cloud model. It extends
SolarAPIto compute and store newpv_clearskyarrays (supporting multiple native upstream sources likeha_solcast_clearsky,solcast_api, andopenmeteo). Clear-sky arrays are used alongside a lightweight auto-tuner to safely estimate peak generation and align it with hardware limits.Resolves issue #1206, supersedes PR #4036.
Key Features:
ha_solcast_clearskyintegration alongside a robustclipping_auto_tunemechanism. This explicitly accounts for those short "break in the clouds" spikes, ensuring the buffer is safely sized even when the standard hourly forecast is smoothed out.solcast.pywith safefloat(val or 0.0)casting to gracefully handle missing HA clear-sky sensor history without crashing.Configuration Parameters:
clipping_buffer_enable: Master toggle for the clipping buffer feature.clipping_clearsky_source: Selection of clear-sky forecast source (recommendsha_solcast_clearsky). This setting is fully exposed in the Home Assistant configuration panel.clipping_use_clearsky_peaks: Toggle to use Clear-Sky generation arrays rather than standard PV forecast arrays to size the buffer.clipping_auto_tune: Automatically learns the scale difference between standard forecasts and hardware limits based on past clipping behavior.clipping_amplification: Manual multiplier for the standard solar forecast (used if Auto-Tune is disabled).clipping_cost_weight: Multiplier to add a harsher financial penalty for clipping, forcing the optimizer to prioritize creating headroom.clipping_limit_override: Manual configuration of the inverter AC ceiling in Watts.clipping_buffer_max_kwh/start_time/end_time: Manual settings to force a fixed static buffer size and time window instead of using the dynamic calculation.Developed with Gemini ✦