“EnCoDaPy” – Energy Control and Data Preparation in Python
Overview
The Basic Service provides a system to
read a configuration
receive data
start a calculation
return the results
This interaction is possible with several interfaces, see examples/03_interfaces:
FIWARE-API
MQTT
File
The controller has the functionality to read a configuration from JSON and ENV, validate it and return it as a model.
The framework provides components that can be used within a service. This is the recommended solution for running a functional service. For more information and code, see: encodapy/components/readme.md
Further documentation can be found here.
Examples and documentation for each part of the project are available under: examples
Configuration
The configuration of the service must be provided via
config.jsonand has several sections (see the documentation or the examples):name: Controller name - for documentation purposes onlyinterfaces: Indicates which interfaces are activeinputs: Configuration of the inputs to the controlleroutputs: Configuration of the outputsstaticdata: Static data point configuration (Data that is not continuously updated)controller_components: Configuration of the controller components, see encodapy/components/readme.md or the documentationcontroller_settings: General settings about the controller
Environmental variables are required to configure the basic service and the interfaces. For more information, see encodapy/config/env_values or the documentation.
Usage
You could install the Package via PyPI:
pip install encodapy
There are two ways to use the Package:
Customer service based on the ControllerBasicService
To create your own custom service, you have to overwrite two functions of the ControllerBasicService:
prepare_start(): This is a synchronous function that prepares the start of the algorithm and specifies aspects of the service. This should not take long due to health issues in Docker containers. It only needs to be overwritten if other tasks are required after initialisation of the service.calculation(): Asynchronous function to perform the main calculation in the servicecalibration(): Asynchronous function to calibrate the service or coefficients and update StaticData in the service if only required
To start the service, you need to call
start_calibration(): To start the calibration if requiredstart_service(): To start the service
For more details, see the examples
Run Components with the ComponentRunnerService
You could use components to run them with the ComponentRunnerService
Frist, create a configuration, then start the service:
as shown in examples/07_component_runner
by running the service with the encodapy.service.service_main function.
If you need additional components, please see encodapy/components:
You can use components from
encodapy/componentsor create your ownAn easy way to build your own component is shown in examples/08_create_new_component
Examples
For different examples and documentation, how to use the tool - see examples.
The examples are intended to help you use the tool and understand how it works:
the configuration
the use
the components
Units
Inputs and outputs get information about the unit. The class
DataUnitsis used for this.More units must be added manually.
Timeranges:
Timeranges for data queries are different for calculation and calibration.
The following timeranges are possible
‘“minute”’
‘“hour”’
‘“day”’
‘“month”’ (30 days for simple use)
Today, there ist no adjustment for different units. Its a TODO for the future
Deployment
The recommended way to run the service is:
Create a Python environment using Poetry (see pyproject.toml).
Use a Docker container for production deployments (create a custom image using the dockerfile).
License
This project is licensed under the BSD License - see the LICENSE file for details.
Copyright
2024-2025, TUD Dresden University of Technology, Chair of Building Energy Systems and Heat Supply
Acknowledgments
We gratefully acknowledge the financial support of the Federal Ministry for Economic Affairs and Energy.