Dose Optimizer is a Service which optimizes demands of air conditions and charging station for electric cars. The optimization is made based on the following four points:
- Static load profile of a property
- Predicted photovoltaic supply
- Air condition demand
- Charging station demand
The optimization Service consists of five main components
- A Rest Api which is used to perform CRUD operation for optimizations and tenant data.
- An optimization data constructor, which collects weather data, device metadata, and demand data of the optimizations.
- An optimizer which optimizes the demands.
- A MQTT service, which sends the demand values to an mqtt broker.
- A local database, which contains tenant data, device data and optimizations.
The following graphic illustrates the interaction of these components:
The service can be installed in two ways:
- Install npm packages.
npm install
- Build the project.
npm run build
-
Set all environment variables. See
./.env.example
. -
Start app.
npm run start:prod
Requirements for step 4:
- pm2 must be installed globally
The service can be run in develop mode as well, by running:
npm run dev
- Build the app:
npm run build
-
Uset the
./Dockerfile
file to build an docker image of the optimization service. -
Set all environment variables of the
/.env.example
file and start the optimization container.
The source code documentation lies under ./docs.
. It exists as html files, which can be read by any we browser. Only open the ./docs/index.html
file to see the documentation. The documentation is auto generated by typedocs. If in the source code any changes are made, the documentation can be automatically new generated by:
typedoc --out docs/ src/
Requirements:
- typedoc
The service must be started before it can be tested. The optimization algorithm can be tested in two ways:
The virtual tests are carried out in the web browser by calling the following URL: http://host-address/test
.
The host used during installation process before must be used as the host. However, the configurations for the host, must be adjusted in ./test/optimization-plots/config.js
as well before starting the service.
The website http://host-address/test
contains three test scenarios that can be selected via tabs. Each tab contains a graph that contains unoptimized test data. The data of the graph are described in the legend to the right of the graph. There is an "Optimize" button under the unoptimized graphs. If this button is pressed, a new graph appears below that shows the results of the optimization. If you move the mouse pointer over the graphs, its values are displayed in the form of tooltips.
Unit tests are performe by using the following npm command:
npm run test:unit
The service can be controlled via a REST API:
All requests requiring an authentication. The authentication is applied, by sending a bearer token as value of the authentication property in the request headers. In the DOSE architecture, a keycloak service is managing the authentication service. Therefor a file ./keycloak.json
must be created in the project root directory according to the ./keycloak.example.json
file.
Method | Endpoint | Parameter | Response |
---|---|---|---|
GET | /v1/optimizations/:oliId | - | body: optimization object; statusCode: 200 |
POST | /v1/optimizations | body: optimization object | body: optimization object; statusCode: 201 |
DELETE | /v1/optimizations/:optimizationPk | - | statusCode: 200 |
Note:
Optimization object structure, can be found under: ./src/data-models/energy-profiles.ts
Method | Endpoint | Parameter | Response |
---|---|---|---|
GET | /v1/tenant/activation/:oliId | - | body: active: 0/1 statusCode: 200 |
PATCH | /v1/tenant/activation/:oliId | body: {active: 0/1} | statusCode: 200 |
Note:
active: 1 -> optimization mechanism is activated
active: 0 -> optimization mechanism is not activated
All requests against the rest api are logged under: ./logs