2 instances of zigbee2mqtt in hass os

I don’t use the add-on from the add-on store. I also don’t host the Zigbee2MQTT instance on the same machine as Home Assistant, although I believe you can and still make this work if you do.

I have two device “servers”… A Raspberry Pi 3 hosting 2 instances of Z2M in docker containers, and a Libre Computer LePotato running the third Z2M instance plus ZwaveJS in containers. I use an external Mosquito MQTT server (you can use the one in the addon store), then one instance of the MQTT integration.

This keep all Zigbee devices under 1 integration event through they’re all spread across three instances of Z2M. Been running this way over a year now and it’s proven to be very reliable.

1 Like

This is genius. I need to do that on one of my HASS boxes where there are two zigbee networks because they’re too far apart to reach each other.
No need to run z2m on an RPI any more :smile:

I have successfully installed 2 instances, following these instructions and this video

However, i’m getting an error on the second instance, any idea what it is and how to fix it?

Some device has a wrong converter ?

After a LOT of experimentation, I think I figured it out.

I have 14 mmWave sensors that are creating a LOT of traffic, so much, that it’s affecting my other automations, hence the need for a second Z2M instance.

These particular devices didn’t play nice with a second Z2M instance using the trailing"/" method, even with an external converter to handle the newer devices…it’s an ongoing battle with these things.

So…

I made the second instance an “Edge” version, figuring it would have the latest and greatest support.

Suddenly all my errors dissappeared and I now had 2 working instance, no errors and all devices showing up in their respective Z2M devices list.

However, what I couldn’t work out was why, under the HA > System > Devices tab, I could only see the zigbee devices from my second Z2M instance…even though I had configured a different base_topic in the Add On > Z2M > Config “mqtt section”…turns out, this is ignored and has to be set in the configuration.yaml for the respective Z2M instances.


Summary of what worked:

Install 1st instance of Z2M
      then go to…
           HA > Settings > Add On > Z2M > Configuration tab
      Edit the 2 sections, Options & Network as follows

Options

  • data_path - /config/zigbee2mqtt (this was the default path created for me)

  • socat - left this alone

  • mqtt - mqtt://192.168.20.15:1883 (this was my mosquitto address)

  • serial - /dev/ttyUSB0 (my first sonoff coordinator)

Network
port - 8485


Instance 1 notes

  • Mqtt, this is the section that confused me the most, I eventually stripped everything out apart from the server address, I added the details I needed later, in the configuration.yaml file as they were being ignored here.

  • This is the minimum details in the Z2M config tab that are needed to get Z2M running.


Second instance prep
You will have a folder in the HA file system for the first Z2M instance, as denoted above in the data_path.
Manually create a second folder for the second Z2M-Edge instance, this is so you can edit the configuration.yaml files independently later, I called mine, zigbee2mqtt2


Install 2nd instance of Z2M, Edge version
      then go to…
           HA > Settings > Add On > Z2M-Edge > Configuration tab
      Edit the 2 sections, Options & Network as follows

Options

  • data_path - /config/zigbee2mqtt2 (edit to point to the newly created folder)

  • socat - left this alone

  • mqtt - mqtt://192.168.20.15:1883 (same as first instance)

  • serial - /dev/ttyUSB1 (my second sonoff coordinator)

Network
port - 8486 (default is 8485, I incremented by 1 for the second Z2M-Edge instance)


Each instance will now have their own folder in the HA file system.
In each folder there will be a configuration.yaml file, we now need to edit these

Configuration.yaml - First instance

The only thing I changed was the mqtt section:
I added my username and password and most importantly of all, the base_topic, which was being ignored previously

mqtt:
  server: mqtt://192.168.20.15:1883
  base_topic: zigbee2mqtt
  user: mqttuser
  password: mqttpassword

Configuration.yaml - Second instance

I edited the same values, only this time, changing the base_topic to something different

mqtt:
  server: mqtt://192.168.20.15:1883
  base_topic: zigbee2mqtt2
  user: mqttuser
  password: mqttpassword

I made no further changes, including inside the settings section of the Z2M web UI, I just used out of the box.

2 Likes

I came across this thread trying to help someone on FB. I was wondering if someone tried to fork the z2m repo once/multiple times to their own account. This way you can just add your repo’s to HA right. All you have to do extra is keep them up to date. But that should be fairly easy.

I don’t run multiple instances myself (and I run Proxmox). Just a thought…

Edit: to fork a repo multiple times you’ll have to create organization’s. Those don’t need any members or whatsoever. In a little test I got 3 z2m repo’s in my addons list

1 Like

If anyone is willing to test, I created 10 forks.

For the list of url’s, see:
https://github.com/benjamin-dcs/home-assistant/blob/main/README.md#multiple-official-zigbee2mqtt-home-assistant-addons

I do not know if this is know problem, but I realized that when I do a full system reboot, just one of the two Zigbee2mqqt add-ons is getting auto started. The other one just stays there until I manually start it.

Since I do not do a system reboot that often, I always forget to start it before I get complains from the shareholders (Wife and kids).

Hi, I am also experiencing the reboot issue on the 2nd zigbee2mqtt instance. Did anyone manage to resolve this? Thanks

Ya, there was a clue in this thread. So first off you do not need to run zigbee2mqtt in home assistant. I Run my home-assistant instance as a docker container on a synology NAS device (DS918+). I have a mosquitto container setup and running there as well.

I have a steel garage about 300-400ft from my house where I have a ubiquiti building bridge to get high speed network out there. I have a mini 8-port ubiquiti POE switch in the garage powering the other end of the building bridge, a wifi cam, a wifi hotspot and now a UZG-01 Zigbee coordinator. I have that POE Zigbee coordinator setup with a DHCP reservation so it always picks up the same IP address on my IOT subnet. So, that brings us to our 1st Zigbee2mqtt container. That one I have setup normal, but here’s how I have the container setup for those that are interested in running a zigbee2mqtt container outside of home assistant:

My 1st zigbee2mqtt instance I have the UI configured to be accessed on port 8880 (doesn’t really matter, and up to you), and is configured to point to the IP of the UZG-01 device.

My 2nd zigbee2mqtt is setup exactly the same as the one above except I mount a different local folder to the /app/data dir (/volume2/docker/zigbee2mqtt/house_net/app/data). I serve the UI on port 8879, again this is up to you and doesn’t matter. I have 2 of these UZG-01 Zigstar Zigbee ethernet/wifi coordinators. I do this because I have no easy way of continuing the zigbee mesh out to the garage and don’t want to buy a bunch of repeater devices I don’t need.

I was losing my mind as to why my devices kept disappearing after adding the 2nd Zigbee2mqtt instance. So what you need to do to fix is go into your 2nd (or 3rd or Nth instance) and change the following setting under MQTT > Base Topic. This was mentioned above, but if you haven’t played around a ton with MQTT you wouldn’t know where this is set. I changed mine from the default of ‘zigbee2mqtt’ to ‘big_garage_zigbee2mqtt’ (as an example). It just needs to be unique from your other instances.

That should fix it up, but just note you’re probably going to have a bunch of entities to clean up (showing up as unavailable) from when they were being published under a different topic. Now that I know, I’ll never do that again :). Good luck!

Also, when you set this in the UI, it adds this to your configuration.yaml if that’s easier (under mqtt section):

mqtt:
  base_topic: big_garage_zigbee2mqtt

Thanks for the details. I actually have both zigbee2mqtt instances running in HA fine, with different base_topics and directories, working well The only issue I have is the 2nd instance doesn’t start up again after a home assistant restart. Running on a separate device is probably overkill for my needs.

I may go down the path of have an automation to force start the second instance if some of the devices on the second zigbee2mqtt instance are unknown, but would prefer to implement a proper solution.

No need. The Z2MQTT addon itself has a state entity. If it’s working, the state will be Running.

Yours might be disabled by default. You just need to enable it and you’re free to use it in an automation