Skip to content

Feat/efficiencyfield support sensor - #2142

Merged
Flix6x merged 22 commits into
mainfrom
feat/efficiencyfield-support-sensor
May 19, 2026
Merged

Feat/efficiencyfield support sensor#2142
Flix6x merged 22 commits into
mainfrom
feat/efficiencyfield-support-sensor

Conversation

@joshuaunity

Copy link
Copy Markdown
Contributor

Description

This PR extends the support for efficiency-based sensors on the flex-model efficiency fields.

Look & Feel

Before
image

After
image

How to test

  1. Open up an assets flex-model modal dialogue
  2. Look for an efficiency if one is already added, or add a new one
  3. Observe that the "sensor" input tab is now available
  4. Search and add a sensor field
  5. Observe if it successfully updates the modal without any errors

Further Improvements

None

Related Items

This PR closes #2123

Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
@joshuaunity joshuaunity self-assigned this Apr 29, 2026
@read-the-docs-community

read-the-docs-community Bot commented Apr 29, 2026

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #32469607 | 📁 Comparing 0ca0340 against latest (1b609bd)

  🔍 Preview build  

3 files changed
± changelog.html
± _autosummary/flexmeasures.data.schemas.scheduling.storage.html
± api/v3_0.html

Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
@joshuaunity
joshuaunity requested a review from Copilot April 29, 2026 08:59
@joshuaunity joshuaunity added the enhancement New feature or request label Apr 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the storage flex-model configuration (UI + schema/OpenAPI) to allow efficiency fields to be set via sensor references (dynamic signals), aligning with issue #2123.

Changes:

  • Update flex-model schema metadata and UI typing to treat efficiency fields as variable quantities (fixed value or sensor reference).
  • Refactor EfficiencyField to support sensor references and add/extend schema validation tests for efficiency sensors.
  • Regenerate/update OpenAPI specs and add a changelog entry documenting the feature.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
flexmeasures/ui/templates/assets/asset_properties.html Removes typeFive handling so UI backend-types map cleanly to remaining type categories (enabling sensor tab for efficiency fields).
flexmeasures/ui/static/openapi-specs.json Updates OpenAPI schema for roundtrip-efficiency to use VariableQuantityOpenAPI, but also includes an unintended info.version regression.
flexmeasures/data/schemas/tests/test_scheduling.py Adds DB flex-model schema tests for efficiency sensor references and unit convertibility checks.
flexmeasures/data/schemas/scheduling/storage.py Changes EfficiencyField to a VariableQuantityField (sensor-capable), but introduces downstream/runtime + doctest issues.
flexmeasures/data/schemas/scheduling/init.py Changes efficiency fields’ metadata to “fixed or sensor” in the flex-model schema exposed to the UI.
documentation/changelog.rst Adds a changelog bullet for efficiency sensor references in storage flex-models.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread flexmeasures/data/schemas/scheduling/storage.py Outdated
Comment thread flexmeasures/data/schemas/scheduling/storage.py Outdated
Comment thread flexmeasures/data/schemas/scheduling/storage.py Outdated
Comment thread flexmeasures/data/schemas/scheduling/__init__.py
Comment thread flexmeasures/data/schemas/tests/test_scheduling.py
Comment thread flexmeasures/ui/static/openapi-specs.json Outdated
joshuaunity and others added 4 commits April 29, 2026 10:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
…just related schema fields

Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>

@nhoening nhoening left a comment

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.

It seems to work well (I tested the flex-model dialogue for a bit).

Two smaller comments from my side that can be fixed easily by @joshuaunity .

I am not sure if @Flix6x wants to see this, as well.

There is a comment in the issue about testing if the feature set between UI and schema diverges, but it is not specified well yet, and does not need to be part of this PR IMO.

Comment thread documentation/changelog.rst Outdated
Comment thread flexmeasures/data/schemas/tests/test_scheduling.py
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
…Measures/flexmeasures into feat/efficiencyfield-support-sensor
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>

@Flix6x Flix6x left a comment

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.

Nice to see this PR. I think copilot's review deserves another look. I think it correctly flagged that the roundtrip-efficiency field is problematic. Imo it should simply be reverted.

For the storage-efficiency field, the sensor reference is also not without issue, because we are still lacking logic to resample the efficiency from the sensor resolution to the scheduling resolution. I think we should add something of a warning in the UI (info marker?) when the user is about to select (and/or has selected) a sensor for the storage-efficiency. Not sure what a good text is yet. I do like that this field can now be a sensor, too, though!

Comment thread flexmeasures/data/schemas/scheduling/storage.py
Comment thread flexmeasures/data/schemas/scheduling/__init__.py
Comment thread flexmeasures/data/schemas/scheduling/__init__.py
@joshuaunity

Copy link
Copy Markdown
Contributor Author

I think we should add something of a warning in the UI

I can do that.

@joshuaunity

Copy link
Copy Markdown
Contributor Author
image

@Flix6x what do you think?

Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
@Flix6x

Flix6x commented May 4, 2026

Copy link
Copy Markdown
Member

@Flix6x what do you think?

Nailed it! 👌

Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
@joshuaunity

Copy link
Copy Markdown
Contributor Author

@nhoening, this can be merged if there are no more requests.

@nhoening

nhoening commented May 5, 2026

Copy link
Copy Markdown
Member

@Flix6x do you approve?

Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
@Flix6x Flix6x added this to the 0.33.0 milestone May 6, 2026

@Flix6x Flix6x left a comment

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.

No! Please address my review comments, and not just click resolve.

Comment thread documentation/changelog.rst Outdated
Comment thread flexmeasures/ui/static/openapi-specs.json Outdated
Comment thread flexmeasures/data/schemas/scheduling/__init__.py
@Flix6x

Flix6x commented May 6, 2026

Copy link
Copy Markdown
Member

Please do not prompt me for a review again before commenting on each of my review comments.

joshuaunity and others added 2 commits May 6, 2026 10:59
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
@joshuaunity

Copy link
Copy Markdown
Contributor Author

https://github.com/FlexMeasures/flexmeasures/blob/main/flexmeasures%2Fdata%2Fmodels%2Fplanning%2Fstorage.py#L870-L881

Looking at this, the roundtrip_efficiency can't work with sensors at all at the moment. I'm looking at the other fields as well to see if any also fall into a similar situation.

joshuaunity and others added 5 commits May 7, 2026 08:46
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
@joshuaunity

Copy link
Copy Markdown
Contributor Author

@Flix6x, I've looked over the comments and attended to them.

@Flix6x Flix6x left a comment

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.

Great. I only have tiny requests to finish up the PR.

Comment thread documentation/changelog.rst
Comment thread flexmeasures/data/models/forecasting/__init__.py
Comment thread flexmeasures/data/models/forecasting/__init__.py Outdated
)

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.

Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>

@Flix6x Flix6x left a comment

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.

Thanks!

@Flix6x
Flix6x merged commit 2831ca4 into main May 19, 2026
12 checks passed
@Flix6x
Flix6x deleted the feat/efficiencyfield-support-sensor branch May 19, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow efficiency sensors in flex-model

5 participants