No description
Find a file
Pieter Hollander 2ff5a0e04a
All checks were successful
Build Docker image / build (push) Successful in 1m10s
Build Golang packages / release (push) Has been skipped
typo fix
2024-03-25 20:04:49 +01:00
.gitea/workflows Add -v. 2024-02-21 20:09:59 +01:00
docker Add example .env 2024-02-21 11:23:47 +01:00
grafana Add PV.json dashboard 2024-03-18 11:23:12 +01:00
systemd Add systemd configuration. 2024-03-25 10:59:36 +01:00
.gitignore Don't include compiled binary 2024-02-21 15:44:44 +01:00
Dockerfile Upgrade go version. 2024-03-18 10:45:27 +01:00
go.mod Upgrade golang 1.21 -> 1.22 2024-02-21 21:55:53 +01:00
go.sum Go init 2024-02-21 11:22:24 +01:00
LICENSE.md Fix license attribution notice 2024-03-18 12:27:39 +01:00
main.go Update TODOs 2024-03-18 10:47:10 +01:00
README.md typo fix 2024-03-25 20:04:49 +01:00

OpenDTU logger

OpenDTU logger connects to the OpenDTU livedata websocket and captures metrics. These metrics are inserted into a PostgreSQL database. Optionally, TimescaleDB can be used.

Install instructions

Docker

docker pull git.hollander.online/energy/opendtu-logger:0.0

Preferably, run the Docker image using the Docker compose examples provided in the ./docker folder.

Binary

Go to the releases page and download the most recent stable release.

Running the binary as local user

REMOTE_URL="opendtu:80" DB_URL="host=localhost port=5432 user=postgres password=secret dbname=dtu sslmode=disable" TIMESCALEDB_ENABLED="true" TZ="Europe/Amsterdam" ./opendtu-logger

Creating a more permanent setup on Linux using systemd

sudo adduser --system --group --disabled-login --home /opt/opendtu-logger opendtu-logger

sudo mkdir /opt/opendtu-logger
sudo mkdir /opt/opendtu-logger/data
sudo mv ./opendtu-logger /opt/opendtu-logger/

sudo chown -R opendtu-logger:opendtu-logger /opt/opendtu-logger
sudo nano /etc/systemd/system/opendtu-logger.service

Add the contents of systemd/opendtu-logger.service and alter the REMOTE_URL and DB_URL environment variables to match your setup.

PostgreSQL setup

The OpenDTU logger logs to a PostgreSQL database and optionally supports TimescaleDB. Create a separate database and user using the following commands.

CREATE DATABASE opendtu_logger;
CREATE USER opendtu_logger WITH password 'SECRET';
GRANT ALL privileges ON DATABASE opendtu_logger TO opendtu_logger;
GRANT ALL ON SCHEMA public TO opendtu_logger;

Optional: enable TimescaleDB extension

\c opendtu_logger
CREATE EXTENSION OF NOT EXISTS timescaledb;

Environment variables

The following environment variables are required for OpenDTU Logger to be configured.

REMOTE_URL="opendtu:80"
DB_URL="host=localhost port=5432 user=postgres password=secret dbname=dtu sslmode=disable"
TIMESCALEDB_ENABLED="true"
TZ="Europe/Amsterdam"

Grafana

The grafana folder contains example dashboards.

  • The opendtu_ dashboards contain visualisations for each table the OpenDTU logger records to.
  • PV.json is a dashboard which combines the visualisations of each table that I found to be most useful.
  • Zonnepanelen.json is the same as PV.json, but in Dutch language.

Known issues

  • The logger will currently log every event posted by OpenDTU to the websocket. Checks still need to be added to determine the uniqueness of an event. For more information, see also this OpenDTU Github issue.
  • Upon restart of the OpenDTU, OpenDTU Logger will need to be restarted manually as well. Automatic reconnection logic is a work in progress. Using the systemd service file provides a workaround for this.