View on GitHub

smartmetertomqtt

Smart Meter to MQTT application.

Details

This tool reads data from Sml (Smart Message Language) devices or M-Bus devices and publishes the data via MQTT.

Sml support is currently limited to reading.

MQTT is limited to non-SSL (you may easily adopt this…)

Tested with:

Tested on:

Goals:

Depends on:

Installation

Check Releases for a link to amd64 Debian builds. Or build from source:

Prerequisits

Libmbus Libsml and QtMQTT:

cd WHATEVERWORKSPACEYOUWANT
sudo apt install -y git cmake build-essential qtbase5-dev cmake devscripts qtbase5-private-dev debhelper uuid-dev libqt5xmlpatterns5-dev libqt5serialport5-dev dh-make dh-exec
git clone https://github.com/rscada/libmbus
git clone https://github.com/volkszaehler/libsml
git clone https://github.com/qt/qtmqtt

cd libsml 
sed -i 's/.*\s-C\stest$//g' Makefile
dpkg-buildpackage -b --no-sign
cd ..

cd libmbus
./build-deb.sh
cd ..

cd qtmqtt;
QT_VERSION="$(qmake --version | sed -n  's/.*version\s*\([0-9]*\.[0-9]*\.[0-9]*\)\s*.*/\1/p')";
git tag -l | grep -E "${QT_VERSION}$" || QT_VERSION=$(git tag -l | grep -oP "$(qmake --version | sed -n  's/.*version\s*\([0-9]*\.[0-9]*\.\)[0-9]*\s*.*/\1/p')[0-9]+$" | tail -n 1);
git checkout v$QT_VERSION;
cd .. && mv qtmqtt "qtmqtt-$QT_VERSION"; cd "qtmqtt-$QT_VERSION";
qmake;
dh_make -s -c gpl -e none@none.de --createorig -y
dpkg-buildpackage -b --no-sign
cd ..

sudo dpkg -i *.deb

# alternative for mqtt:
#git checkout v$(qmake --version | sed -n  's/.*version\s*\([0-9]*\.[0-9]*\.[0-9]*\)\s*.*/\1/p')
#if no suitable version is found check tags and pick a good one
#qmake
#make
#sudo make install

Compile

git clone https://github.com/oetken/smartmetertomqtt.git
cd smartmetertomqtt
mkdir build
cd build
cmake ..
# for Release mode use: cmake .. -DCMAKE_BUILD_TYPE=Release
cpack
sudo dpkg -i *.deb

Configuration

-> see SmartMeterToMqtt.json_example

Installation as service

Done by the debian package.

Copyright 2021 - 2021, Andreas Oetken and the smartmetertomqtt contributors.