Async client to connect to the FlexMeasures API
Project description
FlexMeasures Client
The FlexMeasures Client provides a python package to connect to a FlexMeasures server to manage flexible assets.
The Flexmeasures Client package provides functionality for authentication, posting sensor data, triggering schedules and retrieving schedules from a FlexMeasures instance through the API.
Getting Started
To get started using the FlexMeasures Client package first an account needs to be registered with a FlexMeasures instance or a local FlexMeasures instance needs to be created. Registring a to a FlexMeasures instance can be done through Seita BV. To create a local instance of FlexMeasures follow the FlexMeasures documentation.
In this example we are connecting to localhost:5000, To connect to a different host add the host in the initialization of the client.
Install using pip:
pip install flexmeasures-client
Initialization and Authentication:
from client import FlexMeasuresClient client = FlexMeasuresClient(email="email@email.com", password="pw")
Retrieve available assets and sensors:
assets = await client.get_assets() sensors = await client.get_sensors()
Post a measurement from a sensor:
await client.post_measurements( sensor_id=<sensor_id>, # integer start="2023-03-26T10:00+02:00", #iso datetime duration="PT6H", # iso timedelta values=[1,2,3,4], # list unit="kWh", entity_address=<sensor_entity_address>, # string )
With FlexMeasures a schedule can be requested to optimize at what time the flexible assets can be activated to optimize for price of energy or emissions. The calculation of the schedule can take some time depending on the complexity of the calculations and therefore the requests have been split in a trigger for the schedule and a retrieve schedule call. Trigger a schedule:
schedule_uuid = await flexmeasures_client.trigger_storage_schedule( sensor_id=<sensor_id>, # int start="2023-03-26T10:00+02:00", # iso datetime duration="PT12H", #iso timedelta soc_unit="kWh", soc_at_start=50, #soc_units (kWh) soc_targets=[ { "value": 100, #soc_units (kWh) "datetime": "2023-03-03T11:00+02:00", # iso datetime } ], consumption_price_sensor=<consumption_price_sensor_id>, # int )
The trigger_storage_schedule return a schedule_uuid. This can be used to retrieve the schedule. The client will re-try if until the schedule is available or the MAX_POLLING_STEPS of 10 is reached. Retrieve schedule:
schedule = await flexmeasures_client.get_schedule( sensor_id=<sensor_id>, #int schedule_id="<schedule_uuid>", # uuid duration="PT45M" # iso timedelta )
The schedule returns a Pandas DataFrame that can be used to regulate the flexible assets.
Making Changes & Contributing
This project uses pre-commit, please make sure to install it before making any changes:
pip install pre-commit cd flexmeasures-client pre-commit install
It is a good idea to update the hooks to the latest version:
pre-commit autoupdate
Don’t forget to tell your contributors to also install and use pre-commit.
Note
This project has been set up using PyScaffold 4.4. For details and usage information on PyScaffold see https://pyscaffold.org/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for flexmeasures-client-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6113782638c7cb506b5efaee457a283fdde98e33ca6bd387dbc168e9439736c |
|
MD5 | 5550aa437e482568eb4d2315391a547f |
|
BLAKE2b-256 | d1bab48f3cac98d77a5d8d07fb378578fb900d35b4d79b8dd59f1bb4af3ae95e |
Hashes for flexmeasures_client-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c5981e0c5285c00ffe67eafd7d0e9d59a3f48df4045877a36ccab6a6c66279c |
|
MD5 | 62d91cad54d69891c57eef06f2f39505 |
|
BLAKE2b-256 | d8026c1b76abcba3c951f7f49dc9f3b882e4519a0ded3670a964e058e0d8d186 |