Preload next grid setpoint before optimization run#739
Conversation
|
Korte NL-samenvatting:\n\nDeze wijziging zorgt ervoor dat de vooraf berekende volgende grid setpoint meteen aan het begin van een nieuwe optimalisatierun teruggezet wordt in Home Assistant. Daardoor voorkom je een zichtbare dip/gat rond de kwartier-/uurgrens voordat de nieuwe run zijn eerste setpoint schrijft.\n\nScope is bewust klein gehouden: alleen dao/prog/day_ahead.py met cache + restore-logica (in-memory en bestand), zonder extra configuratievelden. |
There was a problem hiding this comment.
Pull request overview
This PR adds a “next grid setpoint” preload mechanism so Home Assistant can be updated immediately at the start of a new optimization run, reducing visible setpoint gaps at quarter/hour boundaries.
Changes:
- Added an in-memory + JSON file-backed cache for the “next” grid setpoint.
- Restored the cached setpoint to Home Assistant at the beginning of
calc_optimum(). - Persisted the next-interval setpoint at the end of each optimization run.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closing and removing clean variant branch. |
There was a problem hiding this comment.
What I don't understand is: why you want to save/restore the "grid_set_point".
More important seems to me:
- the next feedin of the batterie/batteries
- the next amperes of the ev('s)
Can you explain to my why you make this choice?
It this moment I have to much questions and comments to approve this PR.
|
I see the comments of Copilot. |
|
You are right that the key controls are:
After yesterday’s update, this is exactly what the preload now stores and restores for the first interval:
So the implementation is no longer centered on a generic grid setpoint idea; it is focused on continuity of battery and EV control across runs. I also improved the logging yesterday so it clearly shows which battery and EV values were cached/applied. If helpful, I can still do one final cleanup pass to align naming/comments even more explicitly with battery and EV terminology, but functionally this is already how it works now. |
Summary
This PR preloads the previously computed grid setpoint into Home Assistant at the start of a new optimization run.
Why
At quarter/hour boundaries there can be a short gap before a new optimization result is written, which can make the setpoint appear to "drop" or not be visibly applied in time. By restoring the precomputed next setpoint immediately at run start, the controller behavior stays continuous.
What changed
calc_optimum().entity_set_power_feedin) to avoid introducing new config fields.../data/next_grid_set_point_cache.json).Scope
dao/prog/day_ahead.py.Validation
python3 -m py_compile dao/prog/day_ahead.pyscripts/sync-to-vm.shfor runtime testing.Notes
2026.7.0.rc.