/gotsmart

Slimme Meter (Smart Meter) Prometheus exporter

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

GotSmart

workflow

GotSmart collects information from the Dutch Slimme Meter (translated as Smart Meter) and exports them as Prometheus metrics. For extensive details on the metrics see the docs from Netbeheer Nederland

This project is forked from Harry Metske gotsmart. Harry forked the project from Bas Roovers and Bas forked from Bas van der Lei. Thanks to Harry, Bas and Bas!

I upgraded to go1.17 and am using go modules. I've configured a release pipeline that creates binary releases for both windows and linux, compiled for different CPU architectures.

Setup

Build

cd gotsmart
go mod tidy
make

Run

Specify the serial device that is connected with the Smart Meter, and a non-default listen address:port.

gotsmart -device /dev/ttyS0 -listen-address :8082

If you want to run it as a daemon, use the file /etc/systemd/system/gotsmart.service and fill it with this (example, fixed port and device):

[Unit]
Description=GotSmart, reading your smart meter and providing a prometheus exporter endpoint
Documentation=https://github.com/egbertp/gotsmart
After=network-online.target

[Service]
User=pi
Restart=on-failure

ExecStart=/usr/local/bin/gotsmart -listen-address :8082 -device /dev/ttyUSB0

[Install]
WantedBy=multi-user.target

Then enable and start the service

$ systemctl enable gotsmart.service
$ systemctl start gotsmart.service

Usage

By default gotsmart reads device /dev/ttyAMA0, listens on address:port 0.0.0.0:8080 and exposes the metrics under /metrics.

Docker container

$ docker build -t poteb/gotsmart .

$ docker images

docker images
REPOSITORY         TAG       IMAGE ID       CREATED         SIZE
poteb/gotsmart     latest    30754165bf37   8 seconds ago   11.5MB

Hardware

instructions / remarks supplier cost
Raspberry Pi Zero 2 W (2021) configuration instructions Raspberry Store € 18,95
Zero Essentials Kit N/A Raspberry Store € 6,95
Power adapter (T6716DV) N/A Raspberry Store € 9,95
Slimme Meter Kabel - 1.8 Meter (P1 kabel) N/A SOS Solutions € 19,95
Total without case € 55,80
FLIRC Raspberry Pi Zero Behuizing N/A SOS Solutions € 12,95
Total with case € 68,75

Known errors

Cross compiling to OpenBSD, MacOS (Darwin), and FreeBSD was not successfull due to an error in the github.com/tarm/serial dependency. I hope someone will be able to fix this.

github.com/tarm/serial@v0.0.0-20180830185346-98f6abe2eb07/serial.go:128:28: undefined: Port
github.com/tarm/serial@v0.0.0-20180830185346-98f6abe2eb07/serial.go:139:9: undefined: openPort