Page 1 of 1

Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Tuesday 02 January 2024 20:11
by njlammerts
I had several tries in 2023 to get Docker working with Portainer to run with Mosquitto, Zigbee2MQTT and Domoticz.

Now in 2024 I had some days of holiday, and so I tried again. I have found and read several threads on the Interwebz about this topic, but I find it difficult toe see the tree in the forrest.

https://www.zigbee2mqtt.io/guide/instal ... ocker.html
https://docs.docker.com/engine/install/ ... repository
https://blog.smarterhome.my/how-to-inst ... portainer/
https://mannema.nl/howto-docker.html

The first "problem". is the choice for Docker, Docker Compose or Docker-Compose. After trying several installs (ad give up again)
Today I followed the installation of this link https://mannema.nl/howto-docker.html and this brought me very far.
I mannaged to get Portainer running (the easy part) and then I got Mosquitto and Domoticz running, but I get stuck on getting Zigbee2MQTT working (following the descriptions in the link).
Over time there are several Links explaining how to install with docker, docker compose, docker-compose. But they are not updated to the latest versions and between each other not completely compatible.

I got Zigbee2MQTT to install in docker, but according to Portainer there is something wrong in the configuration and ik keeps on re-starting.

Scherm­afbeelding 2024-01-02 om 20.00.06.png
Scherm­afbeelding 2024-01-02 om 20.00.06.png (181.1 KiB) Viewed 3697 times

Error report from Portainer:

Using '/app/data' as data directory
/app/node_modules/js-yaml/lib/loader.js:183
return new YAMLException(message, mark);
^
YAMLException: duplicated mapping key (6:1)
3 | mqtt:
4 | base_topic: zigbee2mqtt
5 | server: mqtt://172.18.0.2
6 | frontend:
-----^
7 | port: 9080

8 | serial:
at generateError (/app/node_modules/js-yaml/lib/loader.js:183:10)
at throwError (/app/node_modules/js-yaml/lib/loader.js:187:9)
at storeMappingPair (/app/node_modules/js-yaml/lib/loader.js:358:7)
at readBlockMapping (/app/node_modules/js-yaml/lib/loader.js:1173:9)
at composeNode (/app/node_modules/js-yaml/lib/loader.js:1441:12)
at readDocument (/app/node_modules/js-yaml/lib/loader.js:1625:3)
at loadDocuments (/app/node_modules/js-yaml/lib/loader.js:1688:5)
at Object.load (/app/node_modules/js-yaml/lib/loader.js:1714:19)
at Object.read (/app/lib/util/yaml.ts:7:29)
at read (/app/lib/util/settings.ts:333:20)


This is the docker-compose.yaml file:

version: "3.8"
services:
zigbee2mqtt:
container_name: Zigbee2MQTT
image: koenkk/zigbee2mqtt:latest
restart: always
volumes:
- /var/mydata/zigbee2mqtt/data:/app/data
- /run/udev:/run/udev:ro
ports:
# Frontend port
- 9080:9080
environment:
- TZ=Europe/Amsterdam
devices:
# - /dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0:/dev/ttyACM0
- /dev/serial/by-id/usb-Silicon_Labs_slae.sh_cc2652rb_stick_-_slaesh_s_iot_stuff_00_12_4B_00_21_CC_37_E9-if00-port0:/dev/ttyUSB0


configuration file: /var/mydata/zigbee2mqtt/data/configuration.yaml

homeassistant: false
frontend: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://172.18.0.2
frontend:
port: 9080
serial:
port: /dev/ttyUSB0
advanced:
network_key: GENERATE


Any Help is much appreciated

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Wednesday 03 January 2024 8:41
by gizmocuz
And this is exactly why I use docker compose by hand and not use a frontend

a docker compose container you can start in two ways

docker compose up -d

and docker compose up

The option -d is used to launch the container in the background and keep it running.

But if there is a issue, it is best not to use the -d, so you get a log on the console and see what's wrong

Now I recently modified the ZWaveJS-UI wiki page, but the process is the same for installing zigbee2mqtt:

https://www.domoticz.com/wiki/Zwave-JS-UI

One you created the folder, the docker-compose.yml file, you can issue the docker compose up cmd and see what is wrong.
Make sure you disable the one in Portainer otherwise you might have a conflict for the port number

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Wednesday 03 January 2024 9:32
by jvdz
I think you mean that the shown error is from the running Zigbee2mqtt LOG, when you click the log in the portainer interface...right?
You really should post your yml in a codebox so we can see the spacing used as well, but I assume zigbee2mqtt is conplaing about:

port: 9080
serial:
port: /dev/ttyUSB0
advanced:
network_key: GENERATE

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Wednesday 03 January 2024 9:55
by Derik
Perhaps a option to share here the docker compse files that a working?

I search a lot on the web for working files... Unlles i know what is was doing :-)
Works with docker only is everything is working like mentioned, i do not now..

When you understand docker it is a nice system..

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Wednesday 03 January 2024 17:15
by waltervl
As your systems are different, the docker compose configuration will be different too. Searching this forum should give you some examples already.

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Thursday 04 January 2024 14:14
by njlammerts
I am at the point to start from scratch again. I removed al the containers (domoticz, zigbee2mqtt, Mosquitto) from Portainer (only thing running) and wanted to reload the *.yml files but got several errors of version conflict in /usr/local/*.* files

I searched the forum several times and found much examples, but they are not consistent among each other also. one uses this statement and an other example uses yet a different statement.

Even when I follow the distributions of the "official docker" pages from Domoticz, I get different setup distributions and different outcomes
https://www.domoticz.com/wiki/Docker
https://github.com/domoticz/domoticz-docker
This makes me somewhat irritated, why is it so hard to get 1 dedicated installation description in stead of the different ones (all made with good intentions)

i realy want to understand docker and I think I get it in headlines, the different ways of installing docker, docker compose, docker-compose yml/yaml doesnt make it any easier though.

my goal is to run Domoticz, Mosquitto, zigbee2mqtt in docker/portainer . I don't want to develop docker yml configuration files, but do a 1 time setup with will work for a certain amount of time.


there is a lot of knowledge on the forum and It would be much appreciated if someone would help me to get these 3 apps to get installed.
a step by step description would be nice in stead of pointing out to a direction where it might can be found or to say what is wrong, I know that it is wrong, because it is not working....... please help me on the way to get it working :roll:

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Thursday 04 January 2024 15:47
by Derik
My docker compose:

Code: Select all

version: '3.3'

services:
  domoticz:
    image: domoticz/domoticz:beta
    container_name: domoticz
    restart: unless-stopped
    # Pass devices to container
    devices:
     - /dev/ttyACM0:/dev/ttyACM0-Zwave 
     - /dev/ttyUSB0:/dev/ttyUSB-P1
     - /dev/ttyUSB1:/dev/ttyUSB-RFX433
     - /dev/ttyUSB2:/dev/ttyUSB-Zigbee

    ports:
      - "8080:8080"
    volumes:
      - ./config:/opt/domoticz/userdata
     # -./opt/domoticz/scripts/lua/JSON.lua
      - ./home/pi/domoticz/templates:/opt/domoticz/www/templates

    environment:
      - TZ=Europe/Amsterdam
      - LOG_PATH=/opt/domoticz/userdata/domoticz.log

I did an normal docker install
And then use this docker compose for my docker.. Perhaps change the usb devices

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Thursday 04 January 2024 17:24
by Kedi
I think that the ip address of the mqtt server should be the 'local' ip (127.0.0.1) or the ip of the device it self.
Not the ip of the docker mqtt container. But I might be wrong.

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Thursday 04 January 2024 18:15
by njlammerts
I started new again.
Clean Pi OS install, update&upgrade
Portainer install:
https://pimylifeup.com/raspberry-pi-portainer/

Domoticz install:
https://github.com/domoticz/domoticz-docker (using "docker compose up -d") ( "docker-compose up -d" gave error)

Unfortunatly the "user data" folder is not created by docker (as should according the installation text) Where to put the Python scripts?

I used "- /dev/serial/by-id/usb-Silicon_Labs_slae.sh_cc2652rb_stick_-_slaesh_s_iot_stuff_00_12_4B_00_21_CC_37_E9-if00-port0:/dev/ttyUSB0" for my Zigbee Stick.

This Is my current state at 4-1-2024 18:17

How to get Mosquitto and Zigbee2MQTT get running in their own container and get communicating with each other

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Friday 05 January 2024 12:01
by Kedi
The user_data folder is internal in the container, exposed to the external world in the config folder, which might have to be created manually.
Just check that.
Did you change the ip-adress of mqtt server from my previous post in the zigbee2mqtt config?

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Friday 05 January 2024 16:13
by gizmocuz
Kedi wrote: Thursday 04 January 2024 17:24 I think that the ip address of the mqtt server should be the 'local' ip (127.0.0.1) or the ip of the device it self.
Not the ip of the docker mqtt container. But I might be wrong.
You should use the machine's IP address, not 127.0.0.1 or localhost (192.168.2.3)

Re: Help Needed With Domoticz/Zigbee2MQTT on Docker/Portainer

Posted: Friday 05 January 2024 16:15
by gizmocuz
Derik wrote: Thursday 04 January 2024 15:47 My docker compose:
devices:
- /dev/ttyACM0:/dev/ttyACM0-Zwave
- /dev/ttyUSB0:/dev/ttyUSB-P1
- /dev/ttyUSB1:/dev/ttyUSB-RFX433
- /dev/ttyUSB2:/dev/ttyUSB-Zigbee
I strongly discourage this.... !!! 1000%

You should share the /dev/serial/by-id devices

ls /dev/serial/by-id

like

- /dev/usb-RFXCOM_RFXtrx433_A2Y3NGZL-if00-port0:/dev/ttyUSB-RFX433

Otherwise when your device reboots, or you reorder the usb's you are screwed!