Link Search Menu Expand Document

Smartmeter2mqtt

Smartmeter2mqtt documentation npm docker pulls Support me on Github

github issues Run tests and publish Coverage Status semantic-release

An application that parses smartmeter data over the network or a P1 cable.

Key features

  • Connect to smartmeter over p1 cable or p1-to-socket device.
  • Parse DSMR data
  • Website with real-time-data (over websockets)
  • Output socket to daisy-chain other applications
  • Decrypt Luxemburg smartmeter data

Get Started

You can run this application in several way, docker (compose) is the recommended way.

Choose smartmeter connection

You need to get either a p1-to-tcp or a p1-to-usb device.

Docker

My setup is a Raspberry Pi 3 model b rev 1.2 (See cat /proc/cpuinfo) with a P1 cable running Hypriot as an OS (because of the pre-configured docker/docker-compose).

The docker image is currently automatically build from every new release. We support the following platforms (can be extended if we have someone willing to test it out):

  • AMD64 linux/amd64
  • ARM v6 (raspberry pi ?) linux/arm/v6
  • ARM v7 (raspberry pi 3/3b) linux/arm/v7
  • ARM64 (raspberry pi 4 running in 64 bit) linux/arm64

Docker compose with socket

version: "3.7"

services:
  smartmeter:
    image: svrooij/smartmeter:latest
    restart: unless-stopped
    ports: # Depending on your situation you'll need to expose some ports
      - 3000:3000
      - 3010:3010
      - 3020:3020
    environment:
      - TZ=Europe/Amsterdam
      - SMARTMETER_SOCKET=192.168.1.15:23
      - SMARTMETER_web-server=3000
      - SMARTMETER_tcp-server=3010
      - SMARTMETER_raw-tcp-server=3020
      # - SMARTMETER_enc-key=056F9B0CFEDF150E889BEAD52FA7A174 # if you need to decrypt the messages
      # - SMARTMETER_sunspec-modbus=192.168.x.x # if you want to also read your solar inverter.

Docker compose with usb

If you’re reading from an USB to P1 cable, it’s important that you connect the device to the container. The mapped location might change on reboot or if you connect other devices. That is why I recommend to connect the device by serial. You will need the real device location, type ls /dev/serial/by-id and note the device string that looks like usb-FTDI_FT232R_USB_UART_A13LN4ZS-if00-port0 for my cable.

Be sure to replace this device id in the docker compose file.

version: "3.7"

services:
  smartmeter:
    image: svrooij/smartmeter:latest
    devices: # Replace the device id with your found id, the device is mapped as /dev/ttyUSB0 inside the container.
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A13LN4ZS-if00-port0:/dev/ttyUSB0
    restart: unless-stopped
    ports: # Depending on your situation you'll need to expose some ports
      - 3000:3000
      - 3010:3010
      - 3020:3020
    environment:
      - TZ=Europe/Amsterdam
      - SMARTMETER_PORT=/dev/ttyUSB0
      - SMARTMETER_web-server=3000
      - SMARTMETER_tcp-server=3010
      - SMARTMETER_raw-tcp-server=3020
      # - SMARTMETER_enc-key=056F9B0CFEDF150E889BEAD52FA7A174 # if you need to decrypt the messages
      # - SMARTMETER_sunspec-modbus=192.168.x.x # if you want to also read your solar inverter.

Bare metal

You don’t need docker to run this app, you can also install the app locally and run it from the command line.

  1. Install npm i -g smartmeter2mqtt –production
  2. Figure out how you want connect to your smartmeter.
  3. Start application to see if it works
  4. Configure to run in background see stackoverflow answer.