Transfer zigbee2mqtt from HA to Gladys

Hello everyone :slight_smile:

I’m currently doing HA failover tests to Gladys.
I have zigbee2mqtt on HA as an add-on and I want to transfer my devices without reconfiguration.
Do you have an easy tutorial :slight_smile: (before going through AI lol)
Info: conbee2 as a key

And I have a Sonoff key but there I have devices with ZHA, so I think I don’t have a choice, I’ll have to put them back in Zigbee2mqtt in Gladys I think unless… you never know, it’s almost Christmas.

Thanks for your beautiful answers and have a good weekend.
Olivier

PS: @pierre-gilles ahah

Hi Olivier,

You have two options for your ConBee II, and neither requires you to re-pair your devices.

Option A: Gladys connects to HA’s Zigbee2mqtt

You don’t change anything: Zigbee2mqtt stays on HA and Gladys connects to it via MQTT. This is the quickest way to test.

  1. In HA, create an MQTT user for Gladys in the Mosquitto add-on (or use a dedicated HA user).
  2. In Gladys, go to Integrations → Zigbee2mqtt → Configuration and choose “Connect to an existing installation”.
  3. Enter:
    • the broker URL: mqtt://HA_IP:1883;
    • the MQTT username and password;
    • if you want, the URL of the Zigbee2mqtt web interface.
  4. Your devices appear in the discovery tab. You just have to add them in Gladys.

:warning: Gladys listens to the topic zigbee2mqtt/#: the base_topic of your Zigbee2mqtt must remain zigbee2mqtt, the default value of the add-on.

Advantages: 5 minutes of configuration, nothing to break, immediate rollback.
Disadvantage: you keep HA (Mosquitto + Zigbee2mqtt) running. This doesn’t solve the complete switch, and if it falls, your Zigbee falls too.

Option B: you migrate Zigbee2mqtt to Gladys

Gladys then manages Mosquitto and Zigbee2mqtt itself, and HA can be turned off. Your entire network is in the Zigbee2mqtt data folder, you just need to copy it.

  1. Stop the Zigbee2mqtt add-on in HA, and leave it stopped. Two Zigbee2mqtts must never run on the same network.
  2. With the Samba or SSH add-on, retrieve the Zigbee2mqtt folder (/homeassistant/zigbee2mqtt/ or /config/zigbee2mqtt/ depending on the add-on version):
    • configuration.yaml, and any devices.yaml / groups.yaml;
    • database.db;
    • coordinator_backup.json;
    • state.json (optional).
  3. Place these files on the Gladys machine in /var/lib/gladysassistant/zigbee2mqtt/z2m/. If you have already launched the Zigbee2mqtt integration in Gladys, stop the container first:
docker stop gladys-z2m-zigbee2mqtt
  1. Manually correct these lines in configuration.yaml:
homeassistant: false
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://localhost:1884

server otherwise points to HA’s Mosquitto, and Gladys does not rewrite this line. The rest (MQTT credentials, serial port / adapter, web interface port) is automatically rewritten by Gladys on startup. The network key, PAN ID, and channel are preserved.

  1. Connect the ConBee II to the Gladys machine. In Integrations → Zigbee2mqtt → Configuration, choose “Installation from Gladys”, the USB mode and the model ConBee II, then launch.

Keep a copy of the original folder on the HA side: in case of trouble, you restart the add-on and go back.

:light_bulb: You can chain both options. Start with option A to test Gladys on a daily basis, then move to option B when you’re ready to turn off HA. Devices are attached in Gladys by their Zigbee2mqtt name, and the migration keeps these names. Normally, you don’t have to re-add them in Gladys.

For the Sonoff / ZHA key

This is less simple:

  • ZHA does not use MQTT. Gladys cannot connect to it, and option A does not work for these devices.
  • Gladys only manages one Zigbee2mqtt, so one key. You won’t be able to run the ConBee and the Sonoff in parallel in Gladys.

The simplest and most reliable solution: migrate the ConBee network, then re-pair the devices that were under ZHA. It’s a bit of manipulation once, but after that you have a single clean network, and a mesh that is all the more solid :slightly_smiling_face:

No magic gift for Christmas this time, sorry :grinning_face_with_smiling_eyes:

Keep us posted!

Have a great weekend,

Hello to you, great master :slight_smile:

Oh man, the crazy answer you give me, listen, I finish my coffee, and I’ll try as soon as I can, in any case, even on a Sunday, you’re here, oh no.
A real madman, you shouldn’t be at the pool at this hour, ahahah.

See you later, I’ll keep you updated in any case. (if my wife hasn’t killed me because if I mess this up, it won’t work…)

me again, :slight_smile:

i added it again, I took solution A. the fastest one, everything went well and I select the devices I want to take and when I add it to the Dashboard I get this, nothing comes up.

and I took an existing user so that’s not the problem, if you have any ideas. thanks in advance

ahhh I’m answering myself, I need to learn to read sorry
“Starting this service in ‘Installation from Gladys’ can take between 2 minutes and 1 hour”
I’ll wait then

@OLIVIER if you go to the MQTT integration and look at the Debug page (off the top of your head), do you see anything happening?

it’s good, the values are starting to come in slowly, I’ll wait an hour to see
thanks to you

Had you already taken a look at the following integration?


This would allow you to control it directly without changing anything else.
I also posted a response for a scenario at Rebond sur le sujet : Transfert zigbee2mqtt HA vers Gladys