[SOLVED] MQTT/Zigbee2MQTT not reading the config file (Proxmox VM, portainer stack)

mascal-labo

New Member
Jan 7, 2025
18
0
1
Hello all,

Sorry in advance if I am missing some concepts (read and watched lots of videos but I might be wrong).
[EDIT] I try to run a stack from portainer in a Proxmox VM, Ubuntu 22.04.5 server.

For a new install, I can't get zigbee2mqtt to read the config file properly. I have no error in the container log except that it can't connect to "mqtt://localhost", which is not my setup.
I have the same effect with Mosquitto, but here with an error in the log.
See mosquitto log:
Code:
1737460259: Error: Unable to open config file /mosquitto/config/mosquitto.conf.

See z2m log:
Code:
[2025-01-21 12:53:10] info:     z2m: Connecting to MQTT server at mqtt://localhost
[2025-01-21 12:53:10] error:     z2m: MQTT failed to connect, exiting... ()

I created folders and config files in the VM space:

1737460656363.png

1737460646178.png

Here the content of the config:
Bash:
listener 1883
listener 9001
protocol websockets
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
allow_anonymous true

and

1737460622511.png
Here the content of the config:
YAML:
# Indicates the configuration version (used by configuration migrations)
version: 4

# Home Assistant integration (MQTT discovery)
homeassistant:
    enabled: true

permit_join: true

# Enable the frontend, runs on port 8080 by default
frontend:
    enabled: true
    port: 8080

# MQTT settings
mqtt:
    # MQTT base topic for zigbee2mqtt MQTT messages
    base_topic: zigbee2mqtt
    # MQTT server URL
    server: 'mqtt://172.18.0.3'
    # MQTT server authentication, uncomment if required:
    user: USER
    password: PSSWD

# Serial settings
serial:
    port: /dev/ttyUSB0

# Periodically check whether devices are online/offline
# availability:
#     enabled: false

# Advanced settings
advanced:
    # channel: 11
    # Let Zigbee2MQTT generate a network key on first start
    network_key: GENERATE
    # Let Zigbee2MQTT generate a pan_id on first start
    pan_id: GENERATE
    # Let Zigbee2MQTT generate a ext_pan_id on first start
    ext_pan_id: GENERATE


Here is the docker compose run as stack:
YAML:
services:
  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: unless-stopped
    volumes:
      - $PWD/mosquitto/config:/mosquitto/config
      - $PWD/mosquitto/data:/mosquitto/data
      - $PWD/mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001

  zigbee2mqtt:
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt:latest
    restart: unless-stopped
    volumes:
      - $PWD/zigbee2mqtt/app/data:/zigbee2mqtt/data
      - /run/udev:/run/udev:ro
    ports:
      - 8080:8080
    environment:
      - TZ=Europe/Paris
    devices:
      - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_504fbf9860a4ed11bed084582981d5c7-if00-port0:/dev/ttyUSB0
    logging:
      driver: json-file
      options:
        max-file: 5
        max-size: 10m


and here the VM config:
Bash:
root@myhomelab:~# qm config 121
boot: order=scsi0;ide2;net0
cores: 1
cpu: host
ide2: local:iso/ubuntu_22.04.5_live-server-amd64.iso,media=cdrom,size=2086842K
memory: 2048
meta: creation-qemu=9.0.2,ctime=1736982981
name: full-ha
net0: virtio=BC:24:11:C2:3B:34,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-lvm:vm-121-disk-0,discard=on,iothread=1,size=64G
scsihw: virtio-scsi-single
smbios1: uuid=df6413ad-5f04-49a3-9cd8-68a62885d072
sockets: 1
tags: cpu-host;portainer;ubuntu-server
usb0: host=10c4:ea60
vmgenid: b06442be-5b75-488c-b66d-95e3182ed00d

Thanks in advance!!
 
Last edited:
Your stack uses environment variable $PWD, which points to the current "working directory". This does not necessary have to be /home/pm, so the volume bind mounts may point to the wrong location.

Try replacing "$PWD" by "/home/pm".
 
  • Like
Reactions: mascal-labo
Thanks, so far I tried the format "./mosquitto/config:/mosquitto/config" too without success.
I will try your suggestion...
 
Mosquitto seems to work now, thanks!

1737475908754.png

I still have the same fail with zigbee2mqtt which is falling back on /app/data.

There is a typo above that I corrected, which is now, but that's not doing anything different:

YAML:
    volumes:
      - /home/pm/zigbee2mqtt/data:/zigbee2mqtt/data
 
Last edited:
Yes, I saw that and corrected it, but now it seems to use an old configuration.yaml file.
Should I try to clean the old host folders?
In /var/lib/docker ... ?
 
Yes, this is all done.
Somehow I messed up with the edition of the configuration.yaml file.
I saved one but it got reset to a previous version? Not sure why, probably my fault...

Now it works:

1737482283278.png

Thanks a lot for your help!
 

Attachments

  • 1737481493539.png
    1737481493539.png
    8.7 KB · Views: 1