Backend Services
The following bundles are available in OpenEMS Backend.
This list is not complete. |
1. Metadata File
OpenEMS Backend implementation for Metadata.
Allows you to configure multiple edges by a single JSON file. Using this bundle enables you to easily set up an OpenEMS Backend for testing purposes.
2. Metadata Odoo
Metadata OpenEMS Backend implementation for Odoo.
Enables you to manage multiple edges with one backend.
|
3. Timedata Aggregated InfluxDB
OpenEMS Backend implementation for aggregated InfluxDB access.
Bundle is needed for highly optimized environments with thousands of connected edges only. If you do not need that functionality you can skip this chapter. |
A large number of OpenEMS edges connected to a single backend leads to a performance bottleneck.
The bottleneck is mainly due to the access to the database. This Aggregated InfluxDB
bundle in
combination with the Timedata Influx
bundle can mitigate this bottleneck. This happens by writing all data as usual via Timedata Influx into
an Influx database (DB 1
). Furthermore, all "aggregated data" (see edge datatypes) are written via the Aggregated InfluxDB
bundle to
another database (DB 2
) located on another server.
Thus DB 1
holds all data in high resolution, while DB 2
only holds very few data (5-minute averages for power values
or only daily values for energy). Furthermore, a retention policy of e.g. 90 days is applied to DB 2
.
Thus DB 1
provides relatively slow access to a huge amount of data
and DB 2
provides fast and responsive access to a relatively small database.
Within OpenEMS backend access to both databases is managed by the
TimedataManager.
The TimedataManager writes edge relevant data to all Timedata providers,
whereas it reads data only from the first Timedata provider,
which can deliver.
Assuming correct configuration, TimedataManager first returns historical data
from DB 2
(fast and responsive).
And only in a very few cases it gets the data from DB 1
(probably slower).
The
This list must be adopted to a concrete usecase. It strongly depends on
If you detect some widgets within your OpenEMS-UI which have empty values, it may have to do with an incorrect hardcoded list. |
3.1. Configuration Setup
If you expect your backend to handle thousands of connected edges, the following configuration may provide a good start setup:
Create database and set retention policy:
Before starting the OpenEMS backend and after initially setting up the influx servers,
you need to create the databases influx0
and aggregated0
and some retention policies:
##### Influx Server 1 #####
curl -i -XPOST http://127.0.0.1:8082/query --data-urlencode "q=CREATE DATABASE influx0"
##### Influx Server 2 #####
curl -i -XPOST http://127.0.0.1:8081/query --data-urlencode "q=CREATE DATABASE aggregated0"
curl -i -XPOST http://127.0.0.1:8081/query --data-urlencode "q=CREATE RETENTION POLICY rp_max ON aggregated0 DURATION 90d REPLICATION 1"
curl -i -XPOST http://127.0.0.1:8081/query --data-urlencode "q=CREATE RETENTION POLICY rp_avg ON aggregated0 DURATION 90d REPLICATION 1"
OpenEMS backend configuration:
-
bundle
Timedata.AggregatedInfluxDB
-
ComponentID:
timedata0
-
QueryLanguage:
INFLUX_QL
-
Apikey:
influxuser:influxpassword
-
Bucket:
aggregated0
-
Retention policy for avg values:
rp_avg
-
Retention policy for max values:
rp_max
-
Measurement Avg:
avg
-
Measurement for max values:
Europe/Berlin=max
-
-
bundle
Timedata.InfluxDB
-
ComponentID:
timedata1
-
QueryLanguage:
INFLUX_QL
-
Org:
-
-
Apikey:
influxuser:influxpassword
-
Bucket:
influx0/autogen
-
Measurement:
data
-
-
bundle
Core Timedata-Manager
-
Timedata-IDs:
[timedata0, timedata1]
-
|
4. Timedata Dummy
OpenEMS Backend dummy implementation for a timeseries database.
Using this bundle enables you to easily set up an OpenEMS Backend for testing purposes.
5. Timedata InfluxDB
OpenEMS Backend implementation for InfluxDB.
InfluxDB is an open-source time series database (TSDB). It is optimized for storage and retrieval of time series data.
|
6. Timedata TimescaleDB
OpenEMS Backend implementation for TimescaleDB.
6.1. Setup TimescaleDB on Debian
See https://docs.timescale.com/install/latest/self-hosted/installation-debian/ for reference.
apt install gnupg postgresql-common apt-transport-https lsb-release wget
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
curl -s https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash
apt install timescaledb-2-postgresql-14 timescaledb-tools
timescaledb-tune --quiet --yes
# Open port 5432
vim /etc/postgresql/14/main/postgresql.conf
listen_addresses = '*'
data_directory = '/opt/postgresql'
vim /etc/postgresql/14/main/pg_hba.conf
host all all 0.0.0.0/0 md5
# Firewall
ufw allow to any port 5432
# Apply configuration changes
systemctl restart postgresql
cd /tmp
su postgres -c psql
CREATE DATABASE data;
CREATE USER openems WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE data TO openems;
# Use 'data' db
\c data
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE EXTENSION IF NOT EXISTS tablefunc;
exit