Skip to content

Feat: change toy tutorial to kW units - #2223

Merged
nhoening merged 26 commits into
mainfrom
feat/change-toy-tutorial-to-kw-units
Aug 5, 2026
Merged

Feat: change toy tutorial to kW units#2223
nhoening merged 26 commits into
mainfrom
feat/change-toy-tutorial-to-kw-units

Conversation

@BelhsanHmida

@BelhsanHmida BelhsanHmida commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

  • Change flexmeasures add toy-account to create kW-scale tutorial power sensors.
  • Change the toy account day-ahead price sensor from EUR/MWh to EUR/kWh.
  • Keep tutorial price CSV values in EUR/MWh and load them with --unit EUR/MWh to demonstrate unit conversion.
  • Change toy power flow sensors and schedules from MW-scale to kW-scale.
  • Keep the toy site and battery physical power capacities in 500 kVA.
  • Change the reporter tutorial grid connection capacity from 0.5 MW to 500 kW.
  • Update toy tutorial docs, runnable tutorial scripts, and CI tutorial inputs for the new units.
  • Add regression coverage for battery and reporter toy-account units.
  • Added changelog item in documentation/changelog.rst

Note on data-source IDs: Regenerating the tutorial outputs also shifts the forecast/reporter data-source IDs (forecaster 4→2, reporter 6→3). These are creation-order IDs and are independent of the asset/sensor sequence flexmeasures add toy-account now creates a single data source (toy-user), so the forecaster source becomes 2 and the reporter source 3. The old 4/6 were stale outputs from before that setup was streamlined. (The template assets that raised the sensor/asset IDs create no data sources, which is why sources moved the other way.)

Look & Feel

CLI examples now show kW-scale toy assets and schedules, for example:

Created <Sensor 2: discharging, unit: kW res.: 0:15:00>
Created <Sensor 7: grid connection capacity, unit: kW res.: P1Y>

The rerun toy tutorial plots showed kW labels such as 500kW, 0kW, -500kW, and reporter headroom values around 300kW to 500kW.

Simplified schedule output:

Beliefs for Sensor 'discharging' (ID 2).
Data spans 12 hours and starts at 2026-06-05 07:00:00+01:00.
The time resolution (x-axis) is 15 minutes.

  500kW |        /\                         /\
        |       /  \                       /  \
    0kW |------/----\---------------------/----\-----
        |     /      \                   /      \
 -500kW |____/        \_________________/        \___
             06:00        09:00        12:00        15:00
             discharging (toy-battery)

Simplified reporter output:

Beliefs for Sensor 'headroom' (ID 8).
Data spans a day and starts at 2026-06-05 00:00:00+01:00.
The time resolution (x-axis) is 15 minutes.

  500kW |--------\                              /--------
  400kW |         \____                  ____/
  300kW |              \________________/
             00:00        06:00        12:00        18:00
             headroom (toy-battery)

How to test

run the Docker tutorial scripts in order against a fresh isolated stack:

./documentation/tut/scripts/run-tutorial-in-docker.sh fm1139-server-1
./documentation/tut/scripts/run-tutorial2-in-docker.sh fm1139-server-1
./documentation/tut/scripts/run-tutorial3-in-docker.sh fm1139-server-1
./documentation/tut/scripts/run-tutorial4-in-docker.sh fm1139-server-1
./documentation/tut/scripts/run-tutorial5-in-docker.sh fm1139-server-1

Further Improvements

  • Regenerate and upload the external UI screenshots in the separate FlexMeasures/screenshots repository.

Related Items

Closes #1139.


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: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@Flix6x Flix6x changed the title Feat: change toy tutorial to kw units Feat: change toy tutorial to kW units Jun 5, 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.

Nice, my two main comments are:

  • to actually not change the toy battery and site power capacities from 500 kVA to 500 kW, and
  • to keep the example price data in EUR/MWh, but just scale it to the EUR/kWh sensor unit by explicitly setting the --unit EUR/MWh CLI option of flexmeasures add beliefs.

Also a question: are there screenshots that would need to be updated in https://github.com/FlexMeasures/screenshots (maybe making FlexMeasures/screenshots#8 obsolete by now)?

Comment thread documentation/tut/scripts/run-tutorial-in-docker.sh Outdated
Comment thread .github/workflows/build.yml Outdated
Comment thread documentation/tut/toy-example-setup.rst
Comment thread flexmeasures/cli/data_add.py Outdated
Comment thread flexmeasures/cli/tests/test_data_add_fresh_db.py
@Flix6x Flix6x added documentation Improvements or additions to documentation Units Deals with unit conversion labels Jun 5, 2026
@Flix6x Flix6x added this to the 1.0.0 milestone Jun 5, 2026
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

Nice, my two main comments are:

  • to actually not change the toy battery and site power capacities from 500 kVA to 500 kW, and
  • to keep the example price data in EUR/MWh, but just scale it to the EUR/kWh sensor unit by explicitly setting the --unit EUR/MWh CLI option of flexmeasures add beliefs.

Also a question: are there screenshots that would need to be updated in https://github.com/FlexMeasures/screenshots (maybe making FlexMeasures/screenshots#8 obsolete by now)?

yes that pr is obsolete.

@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. Unless screenshots still need to be updated, I approve.

Comment thread flexmeasures/cli/tests/test_data_add_fresh_db.py
@BelhsanHmida

BelhsanHmida commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Unless screenshots still need to be updated, I approve.

Yes there are photos to be updated. I will make the flexmeasures-screenshot PR and link it to this.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>

# Conflicts:
#	documentation/changelog.rst
#	flexmeasures/cli/tests/test_data_add_fresh_db.py
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@nhoening

nhoening commented Jul 6, 2026

Copy link
Copy Markdown
Member

@BelhsanHmida is this PR mergeable now?

@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

@BelhsanHmida is this PR mergeable now?

I have three more screenshots to generate for the screenshots repo then this can be merged once that's merged.

…ial-to-kw-units

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>

# Conflicts:
#	.github/workflows/docker-build.yml
#	documentation/tut/scripts/run-tutorial-in-docker.sh
#	documentation/tut/scripts/run-tutorial4-in-docker.sh
#	documentation/tut/toy-example-process.rst
#	documentation/tut/toy-example-setup.rst
#	flexmeasures/cli/data_add.py
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

Fixed the stale ID issue in the toy tutorial setup docs. Because template assets are now created before the toy account, the generated toy asset and sensor IDs shifted, so I updated the CLI output, shell-variable flow, sensor links, and referenced IDs to match the fresh tutorial setup.

@BelhsanHmida
BelhsanHmida requested a review from nhoening July 15, 2026 00:41
Signed-off-by: Nicolas Höning <nicolas@seita.nl>

@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.

I approve.

I just want to note that there is a change which this PR is not mentioning, namely the switch of source ID for forecasts in the tutorial, from 4 to 2, and 6 to 3. There is no reason given, but it seems the tutorials pass the GH Action. I assume we did some work on sources previously and this change catches that? If possible, an explanation would be good.
@BelhsanHmida mentioned that IDs for sensors/assets are now higher as we add template assets on startup, but source IDs are decreasing here.

@nhoening

Copy link
Copy Markdown
Member

Also, I am not sure dates are aligning. When the tutorials are run, all dates would be about $TOMORROW, so the day after the tutorial is run.

  • This PR aligns one data from 2022 to 2025, but if we actually re-ran, the dates would all have to be 2026
  • The screenshot PR updates some but not all screenshots, and that also means the dates on the x-axis of plots will not really align.
    This is not very serious, but maybe we want to periodically update and align all of this in one go. This would be something agents can really be helpful for (saving manual work).
    @BelhsanHmida would you open a follow-up issue?

@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

I approve.

I just want to note that there is a change which this PR is not mentioning, namely the switch of source ID for forecasts in the tutorial, from 4 to 2, and 6 to 3. There is no reason given, but it seems the tutorials pass the GH Action. I assume we did some work on sources previously and this change catches that? If possible, an explanation would be good. @BelhsanHmida mentioned that IDs for sensors/assets are now higher as we add template assets on startup, but source IDs are decreasing here.

Updated the PR description to explain the data-source ID change (forecaster 4→2, reporter 6→3) . I've also opened #2369 for the follow-up

Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

@nhoening can i merge this this pr. i was waiting for the screenshots pr to be merged.

@nhoening

nhoening commented Aug 5, 2026

Copy link
Copy Markdown
Member

@nhoening can i merge this this pr. i was waiting for the screenshots pr to be merged.

I approved the screenshot one now! :)

@BelhsanHmida

BelhsanHmida commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@nhoening can i merge this this pr. i was waiting for the screenshots pr to be merged.

I approved the screenshot one now! :)

thanks! can you merge this pr, i don't have authorization to merge fm pr's.

@nhoening
nhoening merged commit dc1fe3b into main Aug 5, 2026
12 of 13 checks passed
@nhoening
nhoening deleted the feat/change-toy-tutorial-to-kw-units branch August 5, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation Units Deals with unit conversion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redo the toy tutorial for scheduling a battery with kW and kWh units

3 participants