Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
00904f4
refactor: refactored SensorsToShowSchema to validate into new shape
joshuaunity Jan 8, 2026
b3afe9e
chore: debugging - work in progress
joshuaunity Jan 8, 2026
af66726
chore: debug errors
joshuaunity Jan 8, 2026
3219aa3
fix: fixed cahrts failing to render
joshuaunity Jan 8, 2026
1611134
chore: udpate test case with new schema changes
joshuaunity Jan 12, 2026
fbb9791
tests: adapting more testcases to new schema shape
joshuaunity Jan 12, 2026
e6babb8
fix: fix failing test
joshuaunity Jan 12, 2026
a1fd936
fix: fixed failing api due to logic oversight
joshuaunity Jan 13, 2026
db3a1fe
fix: handle asset plot entry
joshuaunity Jan 14, 2026
2f2639c
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
joshuaunity Jan 19, 2026
072d1b2
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
joshuaunity Jan 19, 2026
a6dcc6e
chore: add changelog entry
joshuaunity Jan 19, 2026
6fd81be
Update documentation/changelog.rst
joshuaunity Jan 20, 2026
d257c94
Update flexmeasures/data/schemas/utils.py
joshuaunity Jan 26, 2026
6e650de
Update flexmeasures/data/schemas/generic_assets.py
joshuaunity Jan 26, 2026
24cc4a2
Update flexmeasures/data/schemas/generic_assets.py
joshuaunity Jan 26, 2026
328aba7
Update flexmeasures/data/schemas/generic_assets.py
joshuaunity Jan 26, 2026
9d25020
fix: fixed schema bugs
joshuaunity Jan 27, 2026
a6596bc
fix: fixed skipped validation step
joshuaunity Jan 27, 2026
8c01eae
chore: add docstring to schema functions
joshuaunity Jan 28, 2026
39d03c4
chore: little changes
joshuaunity Jan 28, 2026
cf0f180
tests: expanding test case
joshuaunity Jan 28, 2026
41c9e8d
refactor: more backward compatibility refactoring
joshuaunity Jan 28, 2026
577459b
chore: update docstring for SensorsToShowSchema
joshuaunity Jan 28, 2026
68b2ac9
refactor: support for old sensor to show format for flatenen functions
joshuaunity Jan 29, 2026
f65b1b6
tests: change test reference asset
joshuaunity Jan 29, 2026
2bbb7d2
test: apply fixture to test case due to asset resource not found
joshuaunity Jan 29, 2026
2d2eb60
chore: multiple followups across docs and schema based on PR request …
joshuaunity Feb 2, 2026
cb5f009
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
joshuaunity Feb 2, 2026
5e2d55d
fix: fixed failing test
joshuaunity Feb 2, 2026
4d11124
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
joshuaunity Feb 3, 2026
f2d905f
chore: update tpy accoutn data relating to sensors_to_show
joshuaunity Feb 3, 2026
8421d65
Merge branch 'feat/allow-Ssensorstoshow-schema' of github.com:FlexMea…
joshuaunity Feb 3, 2026
c1fd4bf
tests: update test cases
joshuaunity Feb 3, 2026
58af007
refactor: refactored util function for backward compatibility
joshuaunity Feb 3, 2026
a29eda2
tests: fixed failing tests - phase 2
joshuaunity Feb 3, 2026
870fb69
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
nhoening Feb 4, 2026
d13c561
Merge branch 'main' into feat/allow-Ssensorstoshow-schema
joshuaunity Feb 24, 2026
af3f3ca
fix: Fix failing pipeline due to code indentation
joshuaunity Feb 24, 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: 2 additions & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ New features
* Give ability to edit sensor timezone from the UI [see `PR #1900 <https://www.github.com/FlexMeasures/flexmeasures/pull/1900>`_]
* Support creating schedules with only information known prior to some time, now also via the CLI (the API already supported it) [see `PR #1871 <https://www.github.com/FlexMeasures/flexmeasures/pull/1871>`_].
* Add ``fields`` param to the asset-listing endpoints, to save bandwidth in response data [see `PR #1884 <https://www.github.com/FlexMeasures/flexmeasures/pull/1884>`_]
* Support for flex-config in the ``SensorsToShowSchema`` [see `PR #1904 <https://www.github.com/FlexMeasures/flexmeasures/pull/1904>`_]


.. note:: For backwards-compatibility, the new ``fields`` parameter will only be fully active, i.e. also returning less fields per default, in v0.32. Set ``FLEXMEASURES_API_SUNSET_ACTIVE=True`` to test the full effect now.

Expand Down
9 changes: 5 additions & 4 deletions documentation/views/asset-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ Editing the graphs dashboard

Click the "Edit Graph" button to open the graph editor.

Use the "Add Graph" button to create graphs. For each graph, you can select one or more sensors, from all available sensors associated with the asset, including public sensors, and add them to your plot.
Use the "Add Graph" button to create graphs. For each graph, you can select one or more sensors, from all available sensors associated with the asset, including public sensors, and add them to your plot.

You can overlay data from multiple sensors on a single graph. To do this, click on an existing plot and add more sensors from the available options on the right.
In addition, you can add an asset's flex-config to the graph, as long as the value of that config is a sensor(e.g. `[{"title":"Power","plots":[{"sensor":2}]},{"title":"Costs","plots":[{"sensors":[5,6]}]}]`).

Finally, it is possible to set custom titles for any sensor graph by clicking on the "edit" button right next to the default or current title.
Finally, it is possible to set custom titles for any graph by clicking on the "edit" button right next to the default or current title.

.. image:: https://github.com/FlexMeasures/screenshots/raw/main/screenshot-asset-editgraph.png
:align: center
.. :scale: 40%

|

Internally, the asset has a `sensors_to_show` field, which controls which sensor data appears in the plot. This can also be set by a script. The accepted format is a dictionary with a graph title and a lists of sensor IDs (e.g. `[{"title": "Power", "sensor": 2}, {"title": "Costs", "sensors": [5,6] }]`).
Internally, the asset has a `sensors_to_show` field, which controls which sensor data appears in the plot. This can also be set by a script or through the API.
The accepted format is a dictionary with a graph title followed by a plot containing senors or asset fex-config reference(e.g. `[{"title":"Power","plots":[{"sensor":2}]},{"title":"Costs","plots":[{"sensor":5},{"asset":10,"flex-model":"soc-min"},]}]`).


Showing daily KPIs
Expand Down
20 changes: 12 additions & 8 deletions flexmeasures/cli/data_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,19 +1824,23 @@ def create_asset_with_one_sensor(
db.session.flush()
battery = discharging_sensor.generic_asset
battery.sensors_to_show = [
{"title": "Prices", "sensor": day_ahead_sensor.id},
{"title": "Prices", "plots": [{"sensor": day_ahead_sensor.id}]},
{
"title": "Power flows",
"sensors": [production_sensor.id, discharging_sensor.id],
"plots": [
{"sensors": [production_sensor.id, discharging_sensor.id]},
],
},
]

# the site gets a similar dashboard (TODO: after #1801, add also capacity constraint)
building_asset.sensors_to_show = [
{"title": "Prices", "sensor": day_ahead_sensor.id},
{"title": "Prices", "plots": [{"sensor": day_ahead_sensor.id}]},
{
"title": "Power flows",
"sensors": [production_sensor.id, discharging_sensor.id],
"plots": [
{"sensors": [production_sensor.id, discharging_sensor.id]},
],
},
]

Expand Down Expand Up @@ -1876,10 +1880,10 @@ def create_asset_with_one_sensor(

process = shiftable_power.generic_asset
process.sensors_to_show = [
{"title": "Prices", "sensor": day_ahead_sensor.id},
{"title": "Inflexible", "sensor": inflexible_power.id},
{"title": "Breakable", "sensor": breakable_power.id},
{"title": "Shiftable", "sensor": shiftable_power.id},
{"title": "Prices", "plots": [{"sensor": day_ahead_sensor.id}]},
{"title": "Inflexible", "plots": [{"sensor": inflexible_power.id}]},
{"title": "Breakable", "plots": [{"sensor": breakable_power.id}]},
{"title": "Shiftable", "plots": [{"sensor": shiftable_power.id}]},
]

db.session.commit()
Expand Down
9 changes: 8 additions & 1 deletion flexmeasures/data/models/charts/belief_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,14 @@ def chart_for_multiple_sensors(
title = entry.get("title")
if title == "Charge Point sessions":
continue
sensors = entry.get("sensors")
plots = entry.get("plots", [])
sensors = []
for plot in plots:
if "sensors" in plot:
sensors.extend(plot.get("sensors"))
elif "sensor" in plot:
sensors.extend([plot.get("sensor")])

# List the sensors that go into one row
row_sensors: list["Sensor"] = sensors # noqa F821

Expand Down
23 changes: 18 additions & 5 deletions flexmeasures/data/models/generic_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def validate_sensors_to_show(
Steps:
- The function deserializes the 'sensors_to_show' data from the database, ensuring that older formats are parsed correctly.
- It checks if each sensor is accessible by the user and filters out any unauthorized sensors.
- The sensor structure is rebuilt according to the latest format, which allows for grouping sensors and adding optional titles.
- The sensor structure is rebuilt according to the latest format, which allows for grouping sensors and adding optional titles, all into a single 'plots' array.
Details on format:
- The 'sensors_to_show' attribute is defined as a list of sensor IDs or nested lists of sensor IDs (to indicate grouping).
Expand All @@ -247,8 +247,8 @@ def validate_sensors_to_show(
2. List with titles and sensor groupings:
sensors_to_show = [
{"title": "Title 1", "sensor": 40},
{"title": "Title 2", "sensors": [41, 42]},
{"title": "Title 1", "plots": [{"sensor": 40}]},
{"title": "Title 2", "plots": [{"sensors": [41, 42]}]},
[43, 44], 45, 46
]
Expand Down Expand Up @@ -287,6 +287,7 @@ def validate_sensors_to_show(

sensor_ids_to_show = self.sensors_to_show
# Import the schema for validation
from flexmeasures.data.schemas.utils import extract_sensors_from_flex_config
from flexmeasures.data.schemas.generic_assets import SensorsToShowSchema

sensors_to_show_schema = SensorsToShowSchema()
Expand Down Expand Up @@ -324,7 +325,17 @@ def validate_sensors_to_show(
for entry in standardized_sensors_to_show:

title = entry.get("title")
sensors = entry.get("sensors")
sensors = []
plots = entry.get("plots", [])
if len(plots) > 0:
for plot in plots:
if "sensor" in plot:
sensors.append(plot["sensor"])
if "sensors" in plot:
sensors.extend(plot["sensors"])
if "asset" in plot:
extracted_sensors = extract_sensors_from_flex_config(plot)
sensors.extend(extracted_sensors)

accessible_sensors = [
accessible_sensor_map.get(sid)
Expand All @@ -334,7 +345,9 @@ def validate_sensors_to_show(
inaccessible = [sid for sid in sensors if sid not in accessible_sensor_map]
missed_sensor_ids.extend(inaccessible)
if accessible_sensors:
sensors_to_show.append({"title": title, "sensors": accessible_sensors})
sensors_to_show.append(
{"title": title, "plots": [{"sensors": accessible_sensors}]}
)

if missed_sensor_ids:
current_app.logger.warning(
Expand Down
Loading