Skip to content

Backport PR #2884: Restore the soc-min default of 0 for storage (#2884) - #2951

Merged
Flix6x merged 1 commit into
1.1.xfrom
backport/2884-to-1.1.x
Dec 3, 2026
Merged

Flix6x merged 1 commit into
1.1.xfrom
backport/2884-to-1.1.x

Conversation

@Flix6x

@Flix6x Flix6x commented Dec 2, 2026

Copy link
Copy Markdown
Member

Backports #2884 (restore the soc-min default of 0 for storage) to the 1.1 line, for v1.1.4.

git cherry-pick -x -s 2429a0d8f (#2884's squash commit), signed off. The code, the toy battery's flex-model and the new tests apply as on main; only these needed resolving:

  • Changelog: the entry goes in a new v1.1.4 section, with main's wording (1.1.x has Leave forecast soc-usage or soc-gain out at a price, rather than fail to schedule #2920, so the soc-delta-breach-price half holds here).
  • API changelog: the entry goes in a new v3.0-37 (FlexMeasures v1.1.4) section. Like the 1.0 line's patch releases, it keeps the line's API version, as v3.0-38 is main's.
  • test_scheduling.py: only Restore the soc-min default of 0 for storage #2884's new test is added. main's other tests at the end of the file are for features the 1.1 line doesn't have.
  • OpenAPI spec: it keeps the line's own version (1.1.3) and takes only the soc-min description change. The generate-openapi-specs hook would have bumped the version to 1.1.4, so it was skipped for this commit.

Tested on this branch against a private Postgres: the planning tests, the scheduling schema tests, the schedule API tests and the toy-account CLI tests (results below).

flexmeasures/data/models/planning/tests: 413 passed, 3 xfailed in 62.49s (0:01:02)
flexmeasures/data/schemas/tests/test_scheduling.py: 174 passed in 1.70s
flexmeasures/api/v3_0/tests/test_sensor_schedules.py: 30 passed in 3.81s
flexmeasures/api/v3_0/tests/test_asset_schedules_fresh_db.py: 8 passed in 10.09s
flexmeasures/cli/tests/test_data_add_fresh_db.py: 56 passed in 18.30s

The two new tests (test_battery_solver_defaults_soc_min_to_zero, test_soc_min_description_scopes_its_default_to_energy_units) fail on this branch without the fix.

🤖 Generated with Claude Code

* fix: default soc-min to 0 for storage whose state of charge is known

Since #2221 (v1.0.0), a storage flex-model without soc-min had no lower bound, so a battery could be scheduled into a negative state of charge.
The default now lives in default_soc_min(), which issue #2847 can make unit-aware: 0 is a physical floor for energy stocks, but not for fill levels in, say, degrees Celsius.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* fix: give the toy battery a soc-min of 0 kWh

The toy account's battery set soc-max but no soc-min, so scheduling it without a soc-min in the request let it discharge into a negative state of charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* docs: changelog entries for PR #2884

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* docs: move the PR #2884 changelog entry to a new v1.0.3 section

The fix is to be backported to the 1.0.x branch, so list it under the oldest release that will ship it, as was done for v1.0.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v4StnVB9FyGWKK2tMc
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* docs: move the PR #2884 changelog entry from an unreleased v1.0.3 section to v1.0.4

v1.0.3 was released on November 23 without this fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say in the PR #2884 changelog entry what happens to a soc-usage beyond the stock

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say the soc-min default of 0 applies to energy units only

So the description does not over-promise once a state of charge may come in other units (#2847).
The OpenAPI spec is regenerated, keeping its version at 1.1.1, as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say the PR #2884 changelog entry's point about a negative state of charge once

Signed-off-by: F.N. Claessen <claessen@seita.nl>

---------

Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2429a0d)
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x added bug Something isn't working Scheduling CLI labels Dec 2, 2026
@Flix6x Flix6x self-assigned this Dec 2, 2026
@read-the-docs-community

Copy link
Copy Markdown
📖 59 files changed · 56 modified · 3 deleted

Preview · build overview · flexmeasures · built Dec. 2, 2026, 2:29 p.m. UTC

Flix6x added a commit that referenced this pull request Dec 3, 2026
…ach-price, v1.1.4 does (#2954)

The v1.0.4 entry now reads as on the 1.0.x branch (#2952), where a soc-usage beyond the stock makes the schedule infeasible. The main wording moves to a new v1.1.4 section, for the 1.1.x backport (#2951), which has #2920.

Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Flix6x Flix6x added this to the 1.1.4 milestone Dec 3, 2026
@Flix6x Flix6x changed the title Backport #2884 to the 1.1 line Backport PR #2884: Restore the soc-min default of 0 for storage (#2884) Dec 3, 2026
@Flix6x

Flix6x commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Self-review of the backport. The cherry-pick of 2429a0d is faithful. The code, the toy battery's flex-model, the soc-min description and both new tests are identical to #2884's changes on main. Only the two changelogs were resolved by hand. Checked on the 1.1 line:

  • Without a soc-min, the test battery (from 2.5 MWh, soc-max 4.5 MWh) no longer goes down to −45.5 MWh on 1.1.x; it stops at 0. An explicit soc-min is unchanged.
  • A soc-usage beyond what the stock holds is left out at the soc-delta-breach-price (Leave forecast soc-usage or soc-gain out at a price, rather than fail to schedule #2920 is on this line), and makes the schedule infeasible with relax-soc-constraints off, as the changelog entry says.
  • The two new tests fail on 1.1.x without the fix and pass with it. The planning, scheduling-schema, schedule-API and toy-account CLI tests pass. CI is green.
  • The changelog entry is main's, word for word, in a new v1.1.4 section. The API changelog labels it v3.0-37 (FlexMeasures v1.1.4), as the 1.0 line labels its patch releases.

Retitled to this line's backport convention ("Backport PR #2884: …"), so the squash commit reads like the earlier backports on 1.1.x. Milestone set to 1.1.4 (new), and the released 1.1.3 milestone is closed. main's changelog gets the matching v1.1.4 section in #2954. Squash-merging once CI is green.

@Flix6x
Flix6x merged commit 7cc56c5 into 1.1.x Dec 3, 2026
13 checks passed
@Flix6x
Flix6x deleted the backport/2884-to-1.1.x branch December 3, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CLI Scheduling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant