Interesting. That is a lot of devices.
I will try the normal / edge addon approach. This sounds good. I hope to be able to access both configurations (settings).
I need to run 2 instances, because I use one USB bound stick and in my garden house i have a lan port, where i use a hacked lidl lan->zigbee hub. Zigbee2mqtt can only use one hub at the time, so i need 2 instances if i want to use both.
You’re not kidding. Been building out since moving into this home 8 years ago.
You can’t reach the garden house with a repeater node?
Nope, too far away.
Just in case someone also wants to do this I will write how to do.
Using edge was not the way, this led to a lot of problems and neither of the two versions was stable.
Then I found a hint in the internet. You have to add the repo twice.
One time as:
http://…
and the second time as:
http://…/
Both strings are different, so home assistant adds them.
Now you have zigbee2mqtt twice on the addon install page. You install both and configure only the first.
Change the mqqt topic, the zigbee id (both, the upper value and also the numerical value) and the zigbee channel. Now you can start the first z2m. After this you configure the second z2m and you can also start it.
This way you have two z2m links on the left menu and both instances work perfectly.
Hey, just wanted to know how stable it is? Any issues so far?
Hello. So today I created two instances of zigbee2mqtt.
I did it because Aqara e1 curtain drivers were leaving network every few days.
There is written somewhere on the internet that aqara devices have problems with coexisting with different brand zigbee routers on the same network.
So how I did it?
My HomeAssistant runs under Proxmox on device like Intel NUC.
The simplest way how to do it is to install another instance of Z2M as LXC container. To do that just follow this guideline Proxmox VE Helper Scripts | Scripts for Streamlining Your Homelab with Proxmox VE (you can find zigbee2mqtt in the website menu).
This is something like virtualized linux running under Proxmox (but sharing most of the stuff so not using much RAM). I have gone with the alpine linux version and it consumes 70MB of RAM.
Additionally setup a static ip to the running LXC instance so you can reach it back from the HA.
Just follow the steps for alpine.
To edit Z2M config open a shell console of a running LXC instance and run this command:
nano /etc/zigbee2mqtt/configuration.yaml
In the configuration of Z2M set MQTT server running in your HA as a MQTT server (basically just copy credentials from your original Z2M instance and add correct IP address).
I changed the MQTT topic to zigbee2mqtt2 but I am not sure if that is necessary.
Enable homeassistant in the config so Z2M can create devices in HA.
Set the correct Zigbee device (devices are shared with the Proxmox). Of course you need to have two zigbee dongles for this.
My final config looks like this:
mqtt:
base_topic: zigbee2mqtt2
server: mqtt://YOUR_HA_IP:1883
user: YOUR_MQTT_USERNAME
password: YOUR_MQTT_PASSWORD
serial:
port: /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B001CDDF676-if00
frontend:
port: 8080
homeassistant: true
advanced:
log_level: info
log_output:
- console
- syslog
log_directory: /var/log/zigbee2mqtt
log_syslog:
facility: daemon
path: /dev/log
protocol: unix
app_name: Zigbee2MQTT
eol: /n
host: localhost
localhost: localhost
pid: process.pid
port: 514
type: '5424'
network_key: '!secret.yaml network_key'
pan_id: '!secret.yaml pan_id'
channel: 15
last_seen: ISO_8601
devices: devices.yaml
groups: groups.yaml
availability:
active:
timeout: 10
passive:
timeout: 1000
Now to restart Z2M run:
rc-service zigbee2mqtt restart
You can check logs by running:
cat /var/log/messages
Since we enabled frondend in the config we can reach the Z2M gui from the HA.
For this install Zigbee2MQTT Proxy addon in your HA from the same repository as Zigbee2MQTT.
In the config set the server:
http://YOUR_LXC_INSTANCE_IP:8080
After this setup you can have both Z2M visible and manageable from HA.
No problems, works like a charm. Hope this will not get patched out, because its a very good workaround.
Thanks for this, I would like to try this out myself, so have a few questions:
- In the second instance, you need a separate configuration directory correct? So I think one would have the second instance configured in the AddOn’s UI “Configuration” tab to use a different directory, for example:
data_path: /config/zigbee2mqtt-2
- Hostname: Do the two different instances have different hostnames? (You can see the Hostname on the AddOn’s UI “Info” tab page).
- AddOn Webpage: On the AddOn’s UI “Info” tab page is a button “Open Web UI”. When you click on it, it takes you to the AddOn’s webserver. For the second instance, do you change the configuration’s web port number somehow?
- what is “zigbee id”? Do you mean pan-id and ext-pan-id?
Best Regards
[EDIT] I went ahead and got this working (I think), and made some notes along the way:
- UI->Setttings->Add-Ons->+Add On Store->3-dots->Repository.
I "ADD"ed a respository with the additonal “/” at the end of the URL as tom78 said to do (making ithttps://github.com/zigbee2mqtt/hassio-zigbee2mqtt/
) , and indeed another entry was made (and it looks identical to the first instance’s entry). However after closing this pop-up I did not see the additional instance in the AddOn list. Anyway I did reboot the machine and the additional instance did appear this time (along with additonal instances of Edge and Proxy) in the AddOn Store. Note: there is not any way really to distinguish which one is which. - Host/Docker Name - It turns out that the Hostname and Dockernames for the two instances are different, one will be xxxxxxxx_zigbee2mqtt, the other will be yyyyyyyy_zigbee2mqtt.
- When you click on the 2nd instance of zigbee2mqtt, the regular Add-On “Info” page shows up and there is nothing to distinguish it from the 1st instance except for one thing: the URL in the browser is slightly different. The URL will contain the hostname in the string. Once the instance is running, the “info” page will actually show the hostname.
- Logs sent to the HassOS journal will be prefixed with hostname. However if you use the UI->Settings->System->Log->PullDown you will see two instances to choose from but they have the same name (the last one is the 2nd instance)
- Zigbee2MQTT Web UI: Because the hostnames are different, the same webserver port can be used, so no need to have the front-end use a different port. Note: That the Zigbee2MQTT docs also say “you cannot change the port. The addon will force the frontend to run on port 8099 as Home Assistant Ingress requires this”.
- Configuration (Zigbee2MQTT Add-On “Info” page):
- The SoCat port has to change. When the AddOn starts up it stops and tells you there is something else listening on 8485. I simply incremented it by 1 to 8486
- I did change the configuration directory to
/config/zigbee2mqtt-2
- I did change the MQTT parameters to include the
base_topic
as I changed it tozigbee2mqtt2
- Then next configure which serial port to use, and other things like channel-id, pan-id, ext-pan-id etc.
- There may be other things from an administrative/management standpoint to configure in order to distinguish the two instances, but this is all I have done so far.
If one is curious why I was interested in setting up two instances, its because I have a “sandbox” HA system that I use to play around with so that my “production” HA system won’t be affected. On my sandbox I have HA running on a VM, and I have one instance of Zigbee2MQTT using the SiLabs multiprotocol Add-on (that’s been running for several months now), and now on my second instance I wanted to play around with some VM related mappings of the Physical Zigbee USB Stick to my HA-VM serial port.
Same question here:
I am using several UZG-01 coordinator over Ethernet/PoE and I need to use Zigbee2MQTT for each UZG-01.
HA is installed on a dedicated Debian station (Pc Egines APU with 4GB of RAM). Docker is installed and I installed HA in managed mode. This means HA has control over Docker.
How do I create a Docker instance and integrate in Home-assistant managed? I would like to continue using HA managed but I understand at some point it would be interesting to go plain Docker.
Any solution?
Kind regards,
FF
Hello
Is Home assistant able to detect devices from both zigbee2mqtt instance ?
I just came across this topic trying to set up two instances of zigbee2mqtt aswell.
It didn’t work at first as it was ignoring the different base_topic I tried to change.
I changed it in addon config under “mqtt” but apparently THIS WAS IGNORED
It caused all the entities from the first Z2M instance to vanish from HA once the secondary was started. To be specific only entites from the addon that was (re)started as last worked.
What worked:
Install secondary z2m instance by changing the address
In addon configuration change data path, put your serial config, save and run. Don’t put anything about mqtt there (I am using mosquito broker)
(at this point all your entities from primary addon will disappear from HA)
Open the secondary Z2M, go to settings, mqtt and chage the base topic here in GUI
Restart secondary addon
Restart primary addon - this will bring back all entitites from primary addon
It looks like it is working fine but I am testing it only for last 15minutes or so…
Can you tell me how you got 3? I got by adding an extra / at the end of the URL but cannot figure out the 3rd
two slashes at the end
But three and more slashes don’t work. But another workaround that seems to work is to change https to http and again repeating one slash and two…
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.
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
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.