Skip to content

Smartmeter2mqtt container with webserver and webrequest output setup

Introduction

Smartmeter2mqtt parses smart meter data over the network or through a P1 cable. I used it with a P1 reader connected to Home Assistant, MariaDB and InfluxDB 2.x. While the setup worked well, I decided not to rely too heavily on Home Assistant and aimed to create an interactive dashboard with Budibase.

I planned to save P1 reader data in QuestDB (though InfluxDB was also an option) using Smartmeter2mqtt and n8n. Despite the name “Smartmeter2mqtt,” I didn’t use MQTT, opting for the webrequest output and ensuring the web server was accessible.

For more details, check out the Smartmeter2mqtt GitHub page.

Setup

  1. Create the folders needed by the container

    Run the following commands inside your home folder:

    # Open your terminal application
    cd ~
    mkdir -p smartmeter
    cd smartmeter
  2. Create the script needed to run the container

    Save the following script as smartmeter_run.sh:

    smartmeter_run.sh
    # To create this script use your text editor application, for example Nano
    docker run -d \
    --name=smartmeter \
    --hostname=smartmeter \
    -p 3050:3050 \
    -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 \
    -e TZ=Europe/Amsterdam \
    --restart unless-stopped \
    svrooij/smartmeter:beta
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Optional Replace docker with podman if needed
    • Required Replace port number 3050 (on the left side of : and after the setting SMARTMETER_web-server) with a port number that is available if needed. This is the web server port
    • Required Replace <P1 IP address> with the IP address of the P1 reader. Port 23 is the default telnet port. For testing you could also connect via telnet for example by using Putty to view the P1 reader data
    • Required Replace <post url> with the webhook URL. For example http://N8N_IP_ADDRESS:N8N_PORT/webhook/smartmeter. This setting utilizes the webrequest output to send P1 reader data via a webhook, such as to n8n or Node-RED
    • Optional Replace 300 with another interval if needed. Now every 300 seconds the webrequest output will send P1 reader data via a webhook
    • Optional Add -e SMARTMETER_post-json=false 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 worked for me is by setting it to false
    • Optional Please note that I used the beta svrooij/smartmeter:beta because of, for example, the InfluxDB integration that you could possibly use. The beta version is stable for me
    • Required Replace Europe/Amsterdam with your own timezone. The GENERIC_TIMEZONE setting is used by for example the Cron-Node
  3. Run the script to create the container

    Run the following command:

    # Open your terminal application
    sudo sh smartmeter_run.sh

    The image svrooij/smartmeter:beta is automatically pulled and the container is created.

  4. Check the results

    If needed you can check if the container is running properly.

    You can view the webpage by opening a web browser and going to: http://localhost:3050. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

    Now you can also configure an additional output, such as the webhook or MQTT.

Comments

    No comments found for this note.

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

    Copyright 2021- Fiction Becomes Fact