Feature: flex-context per commodity as list#2235
Draft
Flix6x wants to merge 37 commits into
Draft
Conversation
…mmodity) Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…odity Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ty' into dev/flex-context-as-list Signed-off-by: F.N. Claessen <claessen@seita.nl> # Conflicts: # flexmeasures/ui/static/openapi-specs.json
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Copilot AI
added a commit
that referenced
this pull request
Jun 12, 2026
- Add SensorReferenceSchema import - Override relax_constraints default to True in CommodityFlexContextSchema - Remove duplicate breach price and relax fields from FlexContextSchema - Remove duplicate set_default_breach_prices method from FlexContextSchema Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
- Add SensorReferenceSchema import - Override relax_constraints default to True in CommodityFlexContextSchema - Remove duplicate breach price and relax fields from FlexContextSchema - Remove duplicate set_default_breach_prices method from FlexContextSchema Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
- Test aggregate-consumption and aggregate-production fields - Test SharedSchema fields accessible in FlexContextSchema - Test CommodityFlexContextSchema relax_constraints defaults to True - Test shared currency logic for flex-context listings - Test breach prices in both schemas - Add noqa comment for existing unused variable Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
- Add validator to check prices share same currency across all commodity contexts - Fix test data to use actual fixture sensor names - All new tests now passing Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
- Add aggregate-consumption and aggregate-production to scheduling.rst - Exclude COMMODITY_FLEX_CONTEXT and COMMODITY_FLEX_MODEL from doc test (already documented as "commodity") - Exclude aggregate fields from UI test (not yet supported in UI) Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…g validators in place to forbid that, we actually stop having those fields in the schemas of those fields Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x
commented
Jun 12, 2026
| @pytest.mark.parametrize( | ||
| ["flex_context", "fails"], | ||
| [ | ||
| # Test aggregate-consumption field with sensor reference |
Member
Author
There was a problem hiding this comment.
These test cases are very weak still. They either under-specify or falsely claim what result/behaviour they actually test.
Also, we should verify that the aggregate-consumption/production sensors actually get filled with data, with the correct sign convention and with the expected data source type. I don't think they are, which points to missing logic in the StorageScheduler, where the aggregate power flows get computed from ems_schedule. This should be done per commodity, and ensuring backwards compatibility (in case flex-context has no commodity_contexts, all devices are electric).
…s possible that the entire flex-config is described in the db instead of the trigger message (this cherry-pick was adapted, because the flex-context moved from being documented as a dict to a list) Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
sensor for aggregate-consumption sensor and/or aggregate-production Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ty is defined in the html in 3 places Signed-off-by: F.N. Claessen <claessen@seita.nl>
…gate-production Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ev/flex-context-as-list
Copilot AI
added a commit
that referenced
this pull request
Jun 16, 2026
Context: - PR #2235 tests were weak and under-specified - Need to verify aggregate sensors get filled with data - Need to verify correct sign conventions - Need to verify per-commodity logic and backwards compatibility Change: - New file test_scheduling_aggregate_sensors_fresh_db.py (465 lines) - 5 integration tests verifying aggregate sensor functionality: * Data filling and sign convention (3 parametrized cases) * Per-commodity aggregation (skipped - multi-device complexity) * Backwards compatibility (no commodity_contexts) * Data source type verification - Tests use fresh_db fixture for database modifications - All tests passing (5 passed, 1 skipped) Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Jun 16, 2026
Context: - PR #2235 feedback: aggregate sensors not being filled with data - Missing per-commodity logic in StorageScheduler - Need backwards compatibility (no commodity_contexts = all electric) Change: - New method _compute_commodity_aggregate_schedules (lines 2082-2202) - Reconstructs commodity-to-devices mapping from device models - Computes per-commodity aggregates by summing ems_schedule - Supports aggregate-consumption and aggregate-production sensors - Applies split logic based on which sensors are defined - Maintains backwards compatibility with old format Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Jun 16, 2026
Context: - PR #2235 tests were weak and under-specified - Test comments didn't accurately describe behavior - Need better schema validation coverage Change: - Renamed test_commodity_flex_context_defaults to test_commodity_flex_context_schema_validation - Enhanced docstring to clarify schema validation only - Added 3 new test cases for individual aggregate sensors - Added assertions to verify parsed sensor references - 6 parametrized test cases, all passing Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Jun 16, 2026
Context: - PR #2235 required testing aggregate sensor data filling - Integration tests verify scheduler populates aggregate sensors - Schema validation tests are separate from integration tests Change: - Document integration test pattern for aggregate sensors - Add fresh_db requirement for scheduler integration tests - Document scheduler result format (list[dict] with sensor/data/unit/name) - Add lesson about sign convention verification pattern - Document backwards compatibility testing approach Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Jun 16, 2026
Context: - PR #2235 added _compute_commodity_aggregate_schedules method - Implemented per-commodity aggregate power flow computation - Split logic for consumption vs production sensors Change: - Document aggregate schedule computation pattern - Add commodity_to_devices mapping to scheduler knowledge - Document sign convention handling for aggregate fields - Document integration point in scheduler flow - Add backwards compatibility handling pattern Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Flix6x
commented
Jun 17, 2026
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Signed-off-by: Ahmad Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
aggregate-consumptionandaggregate-productionare the per-commodity replacements ofaggregate-powerdocumentation/changelog.rstLook & Feel
...
How to test
...
Further Improvements
...
Related Items
...