Skip to content

Reduce PV forecast failsafe minimum from 18 to 12 hours#284

Merged
MaStr merged 3 commits intomainfrom
copilot/fix-pv-values-failsafe
Feb 28, 2026
Merged

Reduce PV forecast failsafe minimum from 18 to 12 hours#284
MaStr merged 3 commits intomainfrom
copilot/fix-pv-values-failsafe

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

  • Reduce minimum forecast hours from 18 to 12 in baseclass.py
  • Fix off-by-one: use len(current_aligned_forecast) instead of max(keys()) for interval count check
  • Update error log to report actual interval count
  • Update tests in test_baseclass.py and test_baseclass_alignment.py
  • All 275 tests pass
  • CodeQL: 0 alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>To agressive failsafe for PV values</issue_title>
<issue_description>In the time window between 0.00 and 02.00 o'clock , it seems that the values for production are not correctly delivered, or are not until the end of the day.
And the amount of "hours" may be wrong. If interval_minutes = 60 , 18 slots are ok. For 15 minutes it needs to be 18 * 4 = 60 slots.

I think to reduce the value down to 12 hours , 48 slots a 15 minutes.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

The failsafe in ForecastSolarBaseclass was too aggressive when running
between 0:00-2:00 AM since forecast data may not yet cover 18 hours
ahead. Reduced minimum to 12 hours (12 intervals for 60-min resolution,
48 intervals for 15-min resolution).

Fixes: interval count was also wrong for 15-min resolution (72 != 18*4).
48 slots at 15-min = exactly 12 hours.

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix aggressive failsafe for PV values delivery Reduce PV forecast failsafe minimum from 18 to 12 hours Feb 27, 2026
@MaStr MaStr marked this pull request as ready for review February 27, 2026 10:04
Copilot AI review requested due to automatic review settings February 27, 2026 10:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the solar forecast failsafe to accept shorter PV forecasts during early-night hours by reducing the minimum required forecast horizon from 18 hours to 12 hours, and updates tests accordingly.

Changes:

  • Lowered the minimum forecast-length threshold in the ForecastSolar baseclass from 18h to 12h (including 15-min equivalent).
  • Updated RuntimeError message text to reference 12 hours.
  • Updated unit tests to match the new threshold and adjust insufficient-data fixtures.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/batcontrol/forecastsolar/baseclass.py Lowers the minimum forecast horizon check to 12 hours and updates the emitted error/log messages.
tests/batcontrol/forecastsolar/test_baseclass.py Updates failing test matcher to expect the new 12-hour error message.
tests/batcontrol/forecastsolar/test_baseclass_alignment.py Updates integration tests/matchers and insufficient 15-min test data to reflect the new 12-hour threshold.

@MaStr
Copy link
Owner

MaStr commented Feb 27, 2026

@copilot apply changes based on the comments in this thread

Using max(keys()) gives the largest 0-based index, which is one less
than the actual interval count and causes a spurious failure when data
has exactly the required number of intervals. Switch to len() which
correctly reflects the actual count.

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • test.example.com
    • Triggering command: /usr/bin/python python -m pytest tests/ -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@MaStr MaStr merged commit b9438bc into main Feb 28, 2026
13 checks passed
@MaStr MaStr deleted the copilot/fix-pv-values-failsafe branch February 28, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

To agressive failsafe for PV values

3 participants