Docker - Smartmeter2mqtt Container Setup with Webserver and Webrequest Output


Smartmeter2mqtt is an application that parses smartmeter data over the network or a P1 cable, I use it in combination with a P1 reader ethernet from Marcel Zuidwijk.

Last year I purchased the P1 reader and linked it with Home Assistant.. This works very nicely, but now I’ve decided that I don’t want to become too dependent on Home Assistant. So I want to try to build an interactive dashboard with data from different sources with Budibase (a low-code platform).

I will save the data from the P1 reader in QuestDB (but InfluxDB is also possible) using Smartmeter2mqtt and n8n. Despite the name “Smartmeter2mqtt” I do not use MQTT but I do use the webrequest output. I also make sure that the web server can be accessed.

Installation

Here I describe the installation of the Docker Smartmeter2mqtt container. I run this Docker container on a Ubuntu VM that runs via [[ Proxmox VE ]]. I perform the following on the CLI.

Docker pull command:

docker pull svrooij/smartmeter:beta

Please note that I used the beta because of, for example, the InfluxDB integration that you could possibly use . The beta version is stable for me.

Within my home folder I have created a Docker folder where I create a subfolder for each container:

cd ~
mkdir -p docker/smartmeter
cd docker/smartmeter

Now create a shell script with Nano:

sudo nano smartmeter_run.sh

With this shell script we are going to create the container. Copy the following into smartmeter_run.sh:

docker run -d \
  --name=smartmeter \
  --hostname=smartmeter \
  -p 3050:3050 \
  -e TZ=Europe/Amsterdam \
  -e SMARTMETER_SOCKET=P1_IP_ADDRESS:23 \
  -e SMARTMETER_web-server=3050 \
  -e SMARTMETER_post-url=POST_URL \
  -e SMARTMETER_post-interval=300 \
  -e SMARTMETER_post-json=false \
  --restart unless-stopped \
svrooij/smartmeter:beta

If necessary, adjust the following:

-p 3050:3050
This is the web server port. Choose a port that is still available. Check this with netstat

-e TZ=Europe/Amsterdam
Pick the right timezone

-e SMARTMETER_SOCKET=P1_IP_ADDRESS:23
Replace P1_IP_ADDRESS with the IP address of the P1 reader. Port 23 is the default telnet port. As a test you could also connect using Putty or via telnet (CLI) to test if the P1 reader data can be retrieved

-e SMARTMETER_web-server=3050
Make sure the port (3050) is the same as the port you specified earlier

(OPTIONAL) -e SMARTMETER_post-url=POST_URL
Set this if you want to use the webrequest output to send the P1 reader data via a webhook, for example to n8n, Node-RED etc. Replace POST_URL with the webhook URL. For example: http://N8N_IP_ADDRESS:N8N_PORT/webhook/smartmeter

(OPTIONAL) -e SMARTMETER_post-interval=300
Set this if you want to use the webrequest output to send the P1 reader data via a webhook. For example every 300 seconds

(OPTIONAL) -e SMARTMETER_post-json=false
Set this if you want to use the webrequest output to send the P1 reader data via a webhook. By default the data is posted as form variables, if you want you can have it post as json. The only way this setting worked for me is by setting it to false

Exit Nano with CTRL-X and save the changes.

Start the container:

sudo sh smartmeter_run.sh

Check if the container is running properly.

Using Smartmeter2mqtt

The webpage with the latest data from your smartmeter can now be accessed via the following URL:

http://<IP DOCKER HOST>:3050/

Now you can also configure another output, for example the webhook or MQTT.

See also my notes about updating containers with Portainer or via the CLI. With Synology’s Docker Application, updating a container is also very easy.


Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note


    Notes Graph