We wrote a complete tutorial with the client*, which sets up a HEMS from scratch (from nothing but a FlexMeasures account).
- It creates the whole structure - with PV, battery and a heat pump.
- It loads two weeks of historical data and creates forecasts through the forecasting API.
- It goes through one week in 4h steps, forecasting and scheduling all flexible assets.
This is the resulting dashboard:
Note
The tutorial still uses the CLI for reporting. In future versions, we might make reporting available via the API, as well.
To run the HEMS example (HEMS_setup.py), you'll need an environment in which both flexmeasures (the server) and flexmeasures-client is installed.
We use uv to manage dependencies. First, install uv.
From the flexmeasures-client repository, install the client and the FlexMeasures server:
uv sync
uv add git+https://github.com/flexmeasures/flexmeasures.git@mainOr, alternatively, to install released versions into a fresh project:
uv init my-hems && cd my-hems
uv add flexmeasures-client flexmeasuresNext steps:
- Follow instructions to set up flexmeasures (fresh database, etc).
- Create an organisation account and an admin with:
flexmeasures add account
flexmeasures add user --roles admin- Update the credentials in the
examples/HEMS/const.pyscript accordingly.
Before running the tutorial, make sure to update the connection details and other relevant settings (e.g., host, port, credentials) in examples/HEMS/const.py to match your local FlexMeasures setup. Open three terminals. In the first terminal, run the server:
flexmeasures runIn the second terminal, run a flexmeasures worker that listens to both the scheduling and forecasting queues:
flexmeasures jobs run-worker --queue "forecasting|scheduling"Note: you can run the same command in two terminals (2 workers), to speed up the computation!
In the third terminal, run the client script using the /examples/HEMS folder as the current working directory:
cd examples/HEMS
python3 HEMS_setup.py