Install & maintain openHAB on Raspi in Docker together with Mosquitto, Duplicati, influxDB, Samba etc - Step by step instruction

To answer your question: Yes and no. The configuration is text-only, but if you’ve followed the docker-compose.yml you should see a share wmbusmeters_data if you open the samba share via smb://192.168.0.xxx. :slight_smile:

I have to admit that it’s a bit painful to get wmbusmeters running, but once it’s running, it’s the only part on my entire installation that, since 2 years, just does its job. Haven’t touched the config files ever since. Here’s the link to the official readme and here’s an instruction on how to get things to OH.

If this helps, here are my notes and my config files (as said, done ~ 2 years ago). Let me know if this helps. I might find some time to write a more complete / nicer tutorial.

Work either via Terminal (docker exec -it wmbusmeters /bin/sh) or via the Samba share (smb://192.168.0.150/wmbusmeters_data/logs)

  1. Show what’s coming in already via tail -f /wmbusmeters_data/logs/wmbusmeters.log
  2. Create one file per meter in smb://192.168.0.150/wmbusmeters_data/etc/wmbusmeters.d/nameyourmeter with a text file such as…
name=warmwasserzaehler
id=67552079
driver=mkradio3

or

name=kaltwasserzaehler
id=74302994
key=NOKEY

… that specifies the meter that should be captured.
3. Configure the config file smb://192.168.0.150/wmbusmeters_data/etc/wmbusmeters.conf

# Define Loglevel
# loglevel=debug
loglevel=normal
# Device setting
device=auto:t1,c1
# Following line solves detection problem of AMB8465 on Raspi, see https://github.com/weetmuts/wmbusmeters/issues/336
donotprobe=/dev/ttyAMA0
# device=rtlwmbus(ppm=17) <- This is the line for the Nooelec NESDR stick
# Listento depending on used device (AMB8465 or Nooelec NESDR stick)
listento=c1,t1
# listento=c1,t1,s1 <- This is the line for the Nooelec NESDR stick
# Loglevel
# logtelegrams=true
logtelegrams=false
format=json
# Deactivate the following two lines to reduce logging to protect Raspi SD Card
# meterfiles=/wmbusmeters_data/logs/meter_readings
# meterfilesaction=overwrite
# Logging settings
logfile=/wmbusmeters_data/logs/wmbusmeters.log
meterfilesnaming=name
meterfilestimestamp=day
alarmtimeout=1h
alarmexpectedactivity=mon-sun(00-23)
# ignoreduplicates=false
ignoreduplicates=true
shell=/usr/bin/mosquitto_pub -h mqtt -u <username> -P <password> -i wmbusmeter -t wmbusmeters/readings/$METER_ID -m "$METER_JSON"
alarmshell=/usr/bin/mosquitto_pub -h mqtt -u <username> -P <password> -i wmbusmeter -t wmbusmeters/alarm -m "$ALARM_TYPE $ALARM_MESSAGE"
1 Like

Thank you for your angelic patience and detailed instructions.
I feel that I am very close, but despite many attempts and several hours of searching on the Internet, I still haven’t achieved my goal, which is why I came back with three questions:

1.No meters configured.
So far I’ve been able to access the wmbusmeters_data directory by adding a network location in windows.
I pasted your configuration file then created in windows 5 notepad files with the numbers of meters that my nanocul finds, removed the .txt extension and pasted straight into the directory etc/wmbusmeters.d
After each change in the conf file and meter files, I entered Stacks and restarted the wmbusmeters container.
Unfortunately, it appears in the wmbusmeters.log file after restart

Started config cul on /dev/ttyUSB0 listening on t1
No meters configured. Printing id:s of all telegrams heard!

And then first telegram looks like:

Received telegram from: 70611766
          manufacturer: (TCH) Techem Service (0x5068)
                  type: Cold water (0x72)
                   ver: 0x74
                device: cul
                  rssi: -61 dBm
                driver: mkradio3

I do not understand why, since I have uploaded the cold1766 file
image

in which it is entered:

name=cold70611766
id=70611766
driver=mkradio3

I tried different combinations to make the filename identical to the name parameter inside the file, and also to make them different - no result. What this is about?

  1. The second thing, in the case of configuration made according to the first post, does mosquitto require additional configuration in order to work? I see a running mosquitto container in portainer BUT I can’t log in with MQTTExplorer(windows mqtt client) at 192.168.x.x:1883. From what I can see we didn’t restrict access to mosquitto via the .env file so why can’t I connect?

  2. The third thing: can you write about the updates in Docker by the way?
    While using openhabian you go to openhabian-config and select “02Upgrade system”. What will our updates look like when OH3.5 or other new containers are released?

Will there be a notification about a new version somewhere in the portainar or should we track new software releases ourselves? What about updates to portainer and docker itself?

Please see my additions in the very first post. I included another “Maintenance”-chapter that cover both aspects.

Nope. I read about another container (Centurylinks Watchtower) that can do so, but I refrained from including this.

On the other topics I’ll need some more time to dig into. Will probably write another step-by-step.

1 Like

I included a chapter above on how to configure MQTT. Feel free to have a look.

To come back to this / your last question (just tried to restore my own system as a test and also had problems with wmbusmeters, since no configuration was being taken despite being set): I had a bug in the volume-definition of the wmbusmeters volumes, which I fixed in the stack-definition above.

Please re-deploy from the stack above. What you did sounded correct and should work now.

1 Like

Could you show me where I should set it up?

> rpi4g@raspberrypi:~ $ sudo nano /etc/dphys-swapfile
>   GNU nano 5.4                             /etc/dphys-swapfile *
> # /etc/dphys-swapfile - user settings for dphys-swapfile package
> # author Neil Franklin, last modification 2010.05.05
> # copyright ETH Zuerich Physics Departement
> #   use under either modified/non-advertising BSD or GPL license
> 
> # this file is sourced with . so full normal sh syntax applies
> 
> # the default settings are added as commented out CONF_*=* lines
> 
> 
> # where we want the swapfile to be, this is the default
> #CONF_SWAPFILE=/var/swap
> 
> # set size to absolute value, leaving empty (default) then uses computed value
> #   you most likely don't want this, unless you have an special disk situation
> CONF_SWAPSIZE=100
> 
> # set size to computed value, this times RAM size, dynamically adapts,
> #   guarantees that there is enough swap without wasting disk space on excess
> #CONF_SWAPFACTOR=2
> 
> # restrict size (computed and absolute!) to maximally this limit
> #   can be set to empty for no limit, but beware of filled partitions!
> #   this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it
> #   but is also sensible on 64bit to prevent filling /var or even / partition
> #CONF_MAXSWAP=2048

Could you write tutorial how and what setup Duplicati to backup this Docker to pendrive connected to rpi?

Thanks for the hint, I included an extra comment in the section above.

Btw: Maybe mark the content of your dphys-swapfile as code, so that it doesn’t consume that much space in the thread of this forum.

1 Like

Good point. Please see my addition above. Though I would not recommend this, for the reasons stated above.

1 Like

Done

Thanks!

Here is something from me :wink:

I added frontali log viewer as a container (not sure about that :wink: ) Is it correct?
Here is link for github:

version: '3.8'

services:
  openhab:
    image: openhab/openhab:latest
    container_name: openhab
    depends_on:
      - influxdb
      - mosquitto
    restart: always
    privileged: true
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - data_openhab_conf:/openhab/conf
      - data_openhab_addons:/openhab/addons
      - data_openhab_userdata:/openhab/userdata
    environment:
      TZ: ${TZ}
      OPENHAB_HTTP_PORT: ${OPENHAB_HTTP_PORT}
      OPENHAB_HTTPS_PORT: ${OPENHAB_HTTPS_PORT}
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=${TZ}"
      USER_ID: 999
      GROUP_ID: 994
      # Test to run openHAB with German number format
      # Can be tested by entering "locale" after "docker exec -t -i openhab /bin/bash"
      LANG: uk_UK.UTF-8
      LANGUAGE: uk_UK.UTF-8
      LC_ALL: uk_UK.UTF-8
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    network_mode: host

  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    restart: always
    volumes:
      - data_mosquitto_config:/mosquitto/config
      - data_mosquitto_data:/mosquitto/data
      - data_mosquitto_log:/mosquitto/log
    ports:
      - ${MOSQUITTO_MQTT_PORT}:1883
      - ${MOSQUITTO_MQTTS_PORT}:8883
    environment:
      TZ: ${TZ}
    networks:
      app-nw:
        aliases:
          - mqtt

  influxdb:
    image: influxdb:1.8
    container_name: influxdb
    restart: always
    volumes:
      - data_influxdb:/var/lib/influxdb
      - data_influxdb_config:/etc/influxdb
    ports:
      - ${INFLUXDB_DB_PORT}:8086      
    environment:
      - INFLUXDB_DATA_ENGINE=tsm1
      - INFLUXDB_REPORTING_DISABLED=false
      - INFLUXDB_ADMIN_USER=${INFLUXDB_ADMIN_USER}
      - INFLUXDB_ADMIN_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
      - INFLUXDB_USER=${INFLUXDB_USER}
      - INFLUXDB_USER_PASSWORD=${INFLUXDB_USER_PASSWORD}
      - INFLUXDB_READ_USER=${INFLUXDB_READ_USER}
      - INFLUXDB_READ_USER_PASSWORD=${INFLUXDB_READ_USER_PASSWORD}
      - INFLUXDB_DB=${INFLUXDB_OPENHAB_DB}
      - TZ=${TZ}
    networks:
      app-nw:
      backend-nw:
        aliases:
          - db

  wmbusmeters:
    image: weetmuts/wmbusmeters
    container_name: wmbusmeters
    privileged: true
    # Needs to be changed depending on platform (see https://github.com/weetmuts/wmbusmeters/tree/master/docker)
    platform: linux/armv7
    restart: always
    volumes:
      - data_wmbusmeters_data:/wmbusmeters_data
      - /etc/localtime:/etc/localtime:ro
      - /dev/:/dev/
    networks:
      - app-nw
      - backend-nw

  duplicati:
    image: duplicati/duplicati
    container_name: duplicati
    environment:
      - PUID=0
      - PGID=0
      - TZ=Europe/Warsaw
      - CLI_ARGS= #optional
    volumes:
      - /var/lib/docker/volumes/duplicati_config/_data:/config
      - /var/lib/docker/volumes/duplicati_backups/_data:/backups
      - /var/lib/docker/volumes/duplicati_source/_data:/source
      - /var/lib/docker/volumes/openhab_data_openhab_conf:/source/openhab_conf
      - /var/lib/docker/volumes/openhab_data_openhab_addons:/source/openhab_addons
      - /var/lib/docker/volumes/openhab_data_openhab_userdata:/source/openhab_userdata
      - /var/lib/docker/volumes/openhab_data_mosquitto_config:/source/mosquitto_config
      - /var/lib/docker/volumes/openhab_data_mosquitto_data:/source/mosquitto_data
      - /var/lib/docker/volumes/openhab_data_mosquitto_log:/source/mosquitto_log
      - /var/lib/docker/volumes/openhab_data_influxdb:/source/influxdb
      - /var/lib/docker/volumes/openhab_data_influxdb_config:/source/influxdb_config
      - /var/lib/docker/volumes/openhab_data_wmbusmeters_data:/source/wmbusmeters_data
    ports:
      - 8200:8200
    restart: unless-stopped

  samba:
    image: dperson/samba
    container_name: samba
    restart: always
    ports:
      - "137:137/udp"
      - "138:138/udp"
      - "139:139/tcp"
      - "445:445/tcp"
    healthcheck:  
      disable: true  
    environment:
    - TZ='Europe/Warsaw'
    - PUID=9001
    - PGID=9001  
    - WORKGROUP=workgroup  
    - PERMISSIONS=true
    - RECYCLE=false
    - USER1=pi;raspberry;
    - SHARE1=openhab_conf;/shares/openhab_conf;yes;no;yes;
    - SHARE2=openhab_addons;/shares/openhab_addons;yes;no;yes;
    - SHARE3=openhab_userdata;/shares/openhab_userdata;yes;no;yes;
    - SHARE4=mosquitto_config;/shares/mosquitto_config;yes;no;yes;
    - SHARE5=mosquitto_log;/shares/mosquitto_log;yes;no;yes;
    - SHARE6=wmbusmeters_data;/shares/wmbusmeters_data;yes;no;yes;
    - SHARE7=influxdb;/shares/influxdb;yes;no;yes;
    - SHARE8=docker;/shares/docker;yes;no;yes;
    - SHARE9=log;/shares/log;yes;no;yes;
    volumes:
      - data_openhab_conf:/shares/openhab_conf
      - data_openhab_addons:/shares/openhab_addons
      - data_openhab_userdata:/shares/openhab_userdata
      - data_mosquitto_config:/shares/mosquitto_config
      - data_mosquitto_log:/shares/mosquitto_log
      - data_wmbusmeters_data:/shares/wmbusmeters_data
      - data_influxdb:/shares/influxdb
      - /docker:/shares/docker
      - /var/log:/shares/log

  chronograf:
    image: chronograf:latest
    container_name: chronograf
    restart: always
    ports:
      - '8888:8888'
    volumes:
      - /var/lib/docker/volumes/openhab_data_influxdb/_data:/influxdb
    environment:
      - INFLUXDB_URL=http://db:8086
      - INFLUXDB_USERNAME=$INFLUXDB_USER
      - INFLUXDB_PASSWORD=$INFLUXDB_USER_PASSWORD
    networks:
      app-nw:
      backend-nw:

  frontail:
    image: welteki/frontail-openhab:latest
    container_name: frontail
    restart: always
    ports:
      - "9001:9001"
    volumes:
      - /var/lib/docker/volumes/openhab_data_openhab_userdata/_data:/openhab/userdata:ro \


volumes:
  data_openhab_conf:
  data_openhab_addons:
  data_openhab_userdata:
  data_mosquitto_config:
  data_mosquitto_data:
  data_mosquitto_log:
  data_influxdb:
  data_influxdb_config:
  data_wmbusmeters_data:

networks:
  app-nw:
    internal: false
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: app-${PROJECT_NAME}
  backend-nw:
    internal: true
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: be-${PROJECT_NAME}
1 Like

Could you help me add this image to container?
https://hub.docker.com/r/maretodoric/theengsgateway-arm64

Have you tried searching for a yml-file online? For most Docker containers you find yml-files so that you ideally only have to do minor adjustments.

Help me understand what you did in your updated yml-code. From what I can see frontail is already in my .yml and is (as well) in yours?

Sorry I’m stupid :wink: Don’t know why I didn’t see that.

Hi cplant, I tried redeploy and it doesnt help so today I tried the installation completely again from the scrtach and following the instructions from first post. Unfortunately in the case of wmbusmeter I still get information in the wmbusmeters.log file that No meters configured…
Maybe I should create these configuration files with sudo nano and not with windows notepad?

Sry for delay. First of all: Telegrams are received (which is the tricky part), so it’s “just” about filtering and decrypting the right ones.

Two ideas:

  1. Yep, was also thinking about going the sudo nano-path as well, to make sure it’s not some “Windows-Notepad-problem”.
  2. To make sure that the samba shares don’t point to a directory where wmbusmeters can’t see it (bug in my share-definition), maybe do the configuration in the container itself (docker exec -it wmbusmeters /bin/sh).

To be fair, this was the only part which I did not test on my system because, as said, wmbusmeters is running without problems for some time now.

not so straight I guess :frowning:

Deployment error	failed to deploy a stack: (root) Additional property zigbee2mqtt is not allowed

I tried, among other things, to upload the meter files directly to the /etc directory next to wmbusmeters.conf, but nothing changed - the .log file still indicates “No meters configured”

I also found that yours volume definition:

    volumes:
      - data_wmbusmeters_data:/wmbusmeters_data
      - /etc/localtime:/etc/localtime:ro
      - /dev/:/dev/

is a bit different than definition on docker wmb site:

    volumes:
      - /opt/wmbusmeters:/wmbusmeters_data
      - /etc/localtime:/etc/localtime:ro
      - /dev/:/dev/

however, after applying the second code, I lost access to the wmbusmeters_data directory in windows - probably due to further connections of this line of code with other lines to duplicati and to samba stack.

How I can change permissions for openhab folders ? I want create text rules (copy it from my old server) but I’m get permission error …