From 209a4c86f2b23c1c9a22059e9e946c9296ef0fed Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 12 Jun 2026 13:54:38 +0200 Subject: [PATCH 1/5] fix: wrong data-key due to wrong indentation Signed-off-by: F.N. Claessen --- flexmeasures/api/v3_0/assets.py | 10 +++++----- flexmeasures/ui/static/openapi-specs.json | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/flexmeasures/api/v3_0/assets.py b/flexmeasures/api/v3_0/assets.py index 409abce35a..2bd9912d0f 100644 --- a/flexmeasures/api/v3_0/assets.py +++ b/flexmeasures/api/v3_0/assets.py @@ -107,11 +107,11 @@ def __init__(self, *args, **kwargs): flex_model = fields.List( fields.Nested( storage_flex_model_schema_openAPI(exclude=["asset"]), - required=True, - data_key="flex-model", - metadata=dict( - description="Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", - ), + ), + required=True, + data_key="flex-model", + metadata=dict( + description="Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", ), ) diff --git a/flexmeasures/ui/static/openapi-specs.json b/flexmeasures/ui/static/openapi-specs.json index 3f122566b7..2fa9d466ff 100644 --- a/flexmeasures/ui/static/openapi-specs.json +++ b/flexmeasures/ui/static/openapi-specs.json @@ -6254,10 +6254,10 @@ "example": "PT2H", "format": "duration" }, - "flex_model": { + "flex-model": { "type": "array", + "description": "Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", "items": { - "description": "Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", "$ref": "#/components/schemas/StorageFlexModelSchemaOpenAPI" } }, @@ -6277,6 +6277,7 @@ }, "required": [ "flex-context", + "flex-model", "start" ], "additionalProperties": false From 94abddf340325d7e824334cbbcfa12b9d9ceae82 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Sat, 13 Jun 2026 10:55:14 +0200 Subject: [PATCH 2/5] fix: default flex-model and flex-context to empty list and empty dict, respectively, because it is possible that the entire flex-config is described in the db instead of the trigger message Signed-off-by: F.N. Claessen --- flexmeasures/api/v3_0/assets.py | 4 ++-- flexmeasures/ui/static/openapi-specs.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flexmeasures/api/v3_0/assets.py b/flexmeasures/api/v3_0/assets.py index 2bd9912d0f..e4599e2737 100644 --- a/flexmeasures/api/v3_0/assets.py +++ b/flexmeasures/api/v3_0/assets.py @@ -98,7 +98,7 @@ def __init__(self, *args, **kwargs): flex_context = fields.Nested( flex_context_schema_openAPI, - required=True, + load_default={}, data_key="flex-context", metadata=dict( description="The flex-context is validated according to the scheduler's `FlexContextSchema`.", @@ -108,7 +108,7 @@ def __init__(self, *args, **kwargs): fields.Nested( storage_flex_model_schema_openAPI(exclude=["asset"]), ), - required=True, + load_default=[], data_key="flex-model", metadata=dict( description="Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", diff --git a/flexmeasures/ui/static/openapi-specs.json b/flexmeasures/ui/static/openapi-specs.json index 2fa9d466ff..fd77d18fb0 100644 --- a/flexmeasures/ui/static/openapi-specs.json +++ b/flexmeasures/ui/static/openapi-specs.json @@ -6256,12 +6256,14 @@ }, "flex-model": { "type": "array", + "default": [], "description": "Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", "items": { "$ref": "#/components/schemas/StorageFlexModelSchemaOpenAPI" } }, "flex-context": { + "default": {}, "description": "The flex-context is validated according to the scheduler's `FlexContextSchema`.", "$ref": "#/components/schemas/FlexContextOpenAPISchema" }, @@ -6276,8 +6278,6 @@ } }, "required": [ - "flex-context", - "flex-model", "start" ], "additionalProperties": false From 3ef923aa22a02e6e5d897aa71b660df5e8e5bde7 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Sat, 13 Jun 2026 11:00:59 +0200 Subject: [PATCH 3/5] docs: changelog entry Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 6b59c5447e..d7e64f0924 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -21,6 +21,7 @@ Infrastructure / Support Bugfixes ----------- +* Allow flex-model and flex-context to be missing from scheduling requests, because by now the whole flex-config can be defined on assets (in the db) instead [see `PR #xxxx `_] v0.33.0 | June 1, 2026 From c4244196502788d630206bacffdf9543601d0060 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Sun, 14 Jun 2026 01:32:48 +0200 Subject: [PATCH 4/5] chore: fill in PR number Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index d7e64f0924..1ddfd528a9 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -21,7 +21,7 @@ Infrastructure / Support Bugfixes ----------- -* Allow flex-model and flex-context to be missing from scheduling requests, because by now the whole flex-config can be defined on assets (in the db) instead [see `PR #xxxx `_] +* Allow flex-model and flex-context to be missing from scheduling requests, because by now the whole flex-config can be defined on assets (in the db) instead [see `PR #2237 `_] v0.33.0 | June 1, 2026 From 51f8cd67ea7800755acfab816435a35d565f2f33 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 30 Jun 2026 22:30:10 +0200 Subject: [PATCH 5/5] docs: add comment about overriding (not overwriting) flex-model settings Signed-off-by: F.N. Claessen --- flexmeasures/api/v3_0/assets.py | 2 +- flexmeasures/ui/static/openapi-specs.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flexmeasures/api/v3_0/assets.py b/flexmeasures/api/v3_0/assets.py index 759598667a..11d7ddb441 100644 --- a/flexmeasures/api/v3_0/assets.py +++ b/flexmeasures/api/v3_0/assets.py @@ -119,7 +119,7 @@ def __init__(self, *args, **kwargs): load_default=[], data_key="flex-model", metadata=dict( - description="Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", + description="Flex-model per device (identified by `sensor`). The flex-model may (partly) also be defined on the asset, and sending it here overrides those settings for the schedule at hand. The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", ), ) diff --git a/flexmeasures/ui/static/openapi-specs.json b/flexmeasures/ui/static/openapi-specs.json index fed8c46f8d..af48a5cc66 100644 --- a/flexmeasures/ui/static/openapi-specs.json +++ b/flexmeasures/ui/static/openapi-specs.json @@ -6258,7 +6258,7 @@ "flex-model": { "type": "array", "default": [], - "description": "Flex-model per device (identified by `sensor`). The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", + "description": "Flex-model per device (identified by `sensor`). The flex-model may (partly) also be defined on the asset, and sending it here overrides those settings for the schedule at hand. The flex-model validation is handled by the scheduler. What follows is the schema used by the `StorageScheduler`.", "items": { "$ref": "#/components/schemas/StorageFlexModelSchemaOpenAPI" }