Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
31f8281
refactor: update efficiency field and types in scheduling schemas
joshuaunity Apr 29, 2026
b599e43
test: add tests for efficiency sensors in DBFlexModelSchema
joshuaunity Apr 29, 2026
cf0edab
chore: add changelog entry
joshuaunity Apr 29, 2026
f0fc4c5
Update flexmeasures/data/schemas/scheduling/storage.py
joshuaunity Apr 29, 2026
7772bc2
Update flexmeasures/data/schemas/scheduling/storage.py
joshuaunity Apr 29, 2026
9c72835
Update flexmeasures/ui/static/openapi-specs.json
joshuaunity Apr 29, 2026
7a2925a
refactor: update EfficiencyField to inherit from QuantityField and ad…
joshuaunity Apr 29, 2026
9e00754
fix: restore openapi-specs.json version to 0.32.0
Copilot Apr 29, 2026
6ab9798
test: enhance DB storage flex-model schema tests for sensor references
joshuaunity Apr 29, 2026
85a2cb0
Merge branch 'feat/efficiencyfield-support-sensor' of github.com:Flex…
joshuaunity Apr 29, 2026
0ca0340
chore: udpated docstring
joshuaunity Apr 29, 2026
f5f8d50
feat: add warning for sensor resolution in storage efficiency info cards
joshuaunity May 4, 2026
3f57300
Merge branch 'main' into feat/efficiencyfield-support-sensor
joshuaunity May 5, 2026
057461e
Merge branch 'main' into feat/efficiencyfield-support-sensor
joshuaunity May 6, 2026
0efacb1
chore: resolving changelog conflicts
joshuaunity May 6, 2026
025bf3d
Update API version to 0.32.0
joshuaunity May 6, 2026
1a213b4
feat: update roundtrip efficiency field type and schema description
joshuaunity May 7, 2026
18d2369
Update API version to 0.32.0
joshuaunity May 7, 2026
40a055e
chore: refactored test cases
joshuaunity May 7, 2026
abe7c1e
Merge branch 'main' into feat/efficiencyfield-support-sensor
joshuaunity May 15, 2026
23c6ea0
fix: added support for string only field types
joshuaunity May 18, 2026
b0ff94a
chore: revert few changes
joshuaunity May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Bugfixes
* Make the sensor page load much faster for sensors with lots of data, by avoiding to load statistics over all of its history by default [see `PR #2129 <https://www.github.com/FlexMeasures/flexmeasures/pull/2129>`_]
* Return a clear validation error (instead of a server ZeroDivisionError) when posting instantaneous (0-minute) data to non-instantaneous sensors via ``[POST] /sensors/(id)/data`` [see `PR #2116 <https://www.github.com/FlexMeasures/flexmeasures/pull/2116>`_]
* Fix asset context page for asset names containing apostrophes [see `PR #2117 <https://www.github.com/FlexMeasures/flexmeasures/pull/2117>`_]

* Support sensor references for efficiency fields in storage flex-models [see `PR #2142 <https://www.github.com/FlexMeasures/flexmeasures/pull/2142>`_]
Comment thread
joshuaunity marked this conversation as resolved.
Outdated

v0.32.1 | May XX, 2026
============================
Expand Down
16 changes: 8 additions & 8 deletions flexmeasures/data/schemas/scheduling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,35 +658,35 @@ def _to_currency_per_mwh(price_unit: str) -> str:
"default": None,
"description": rst_to_openapi(metadata.ROUNDTRIP_EFFICIENCY.description),
"types": {
"backend": "typeFive",
"ui": "Fixed value only.",
"backend": "typeThree",
"ui": "One fixed value or a dynamic signal (via a sensor).",
},
"example-units": EXAMPLE_UNIT_TYPES["efficiency"],
},
"charging-efficiency": {
"default": None,
"description": rst_to_openapi(metadata.CHARGING_EFFICIENCY.description),
"types": {
"backend": "typeFive",
"ui": "Fixed value only.",
"backend": "typeThree",
"ui": "One fixed value or a dynamic signal (via a sensor).",
},
"example-units": EXAMPLE_UNIT_TYPES["efficiency"],
},
"discharging-efficiency": {
"default": None,
"description": rst_to_openapi(metadata.DISCHARGING_EFFICIENCY.description),
"types": {
"backend": "typeFive",
"ui": "Fixed value only.",
"backend": "typeThree",
"ui": "One fixed value or a dynamic signal (via a sensor).",
},
"example-units": EXAMPLE_UNIT_TYPES["efficiency"],
},
"storage-efficiency": {
"default": None,
"description": rst_to_openapi(metadata.STORAGE_EFFICIENCY.description),
"types": {
"backend": "typeFive",
"ui": "Fixed value only.",
"backend": "typeThree",
"ui": "One fixed value or a dynamic signal (via a sensor).",
},
Comment thread
Flix6x marked this conversation as resolved.
"example-units": EXAMPLE_UNIT_TYPES["efficiency"],
},
Expand Down
9 changes: 6 additions & 3 deletions flexmeasures/data/schemas/scheduling/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@


class EfficiencyField(QuantityField):
Comment thread
joshuaunity marked this conversation as resolved.
"""Field that deserializes to a Quantity with % units. Must be greater than 0% and less than or equal to 100%.
"""Field that deserializes to a Quantity with % units.
Fixed values must be greater than 0% and less than or equal to 100%.

Examples:

Expand Down Expand Up @@ -435,7 +436,8 @@ class DBStorageFlexModelSchema(Schema):
metadata={"deprecated field": "soc-usage"},
)

roundtrip_efficiency = EfficiencyField(
roundtrip_efficiency = VariableQuantityField(
"%",
data_key="roundtrip-efficiency",
required=False,
metadata={"deprecated field": "roundtrip_efficiency"},
Expand All @@ -455,7 +457,8 @@ class DBStorageFlexModelSchema(Schema):
metadata={"deprecated field": "discharging-efficiency"},
)

storage_efficiency = EfficiencyField(
storage_efficiency = VariableQuantityField(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there no associated change to the openapi-specs.json?

@joshuaunity joshuaunity May 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I don't think they should, as the flex-config schema isn't directly placed on the API's themselves, rather they are used under the hood.

"%",
data_key="storage-efficiency",
required=False,
metadata={"deprecated field": "storage_efficiency"},
Expand Down
21 changes: 20 additions & 1 deletion flexmeasures/data/schemas/tests/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,15 +782,34 @@ def test_get_variable_quantity_unit(
{"soc-usage": ["3500 kW", {"sensor": "power-sensor"}]},
False,
),
(
{"roundtrip-efficiency": {"sensor": "efficiency-sensor"}},
False,
),
(
{"roundtrip-efficiency": {"sensor": "power-sensor"}},
{"roundtrip-efficiency": "Cannot convert MW to %"},
),
(
{"storage-efficiency": {"sensor": "efficiency-sensor"}},
False,
),
(
{"storage-efficiency": {"sensor": "power-sensor"}},
{"storage-efficiency": "Cannot convert MW to %"},
),
Comment thread
joshuaunity marked this conversation as resolved.
],
)
def test_db_flex_model_schema(db, app, setup_dummy_sensors, flex_model, fails):
def test_db_flex_model_schema(
Comment thread
joshuaunity marked this conversation as resolved.
db, app, setup_dummy_sensors, setup_efficiency_sensors, flex_model, fails
):
schema = DBStorageFlexModelSchema()

sensors = {
"energy-sensor": setup_dummy_sensors[0],
"price-sensor": setup_dummy_sensors[1],
"power-sensor": setup_dummy_sensors[3],
"efficiency-sensor": setup_efficiency_sensors,
}

for field_name, field_value in flex_model.items():
Expand Down
1 change: 0 additions & 1 deletion flexmeasures/ui/static/openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,6 @@
},
"/api/v3_0": {},
"/api/v3_0/sensors/data": {},
"/api/v3_0/docs/dist/{filename}": {},
"/api/v3_0/docs/{path}": {},
"/api/dev/sensor/{id}": {},
"/api/dev/sensor/{id}/chart": {},
Expand Down
2 changes: 0 additions & 2 deletions flexmeasures/ui/templates/assets/asset_properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ <h5 class="modal-title pe-2">Edit {{ asset.name }}'s flex-model</h5>
validTypes = [String, Object];
} else if (type === "typeFour") {
validTypes = [Array];
} else if (type === "typeFive") {
validTypes = [String];
}
FlexModelFieldValidTypes[key] = validTypes;
}
Expand Down
Loading