Every day all my MQTT devices are lost in HA :(

First of all, I’m new to this topic and only started using Home Assistant a few weeks ago. I decided to use Zigbee2Mqtt straight away and, due to the size of our house, I use two Z2M containers, each with an SLZB-06M (connected via LAN cable). One directly on the router and one SLZB-06M on a repeater. Now, after a day at the latest, all my devices in the Home Assistant disappear from the “MQTT” integration. But only those that come in directly on the router via the SLZB-06M. Both SLZB-06M (Zigbee2MQTT Bridge) are still visible in MQTT. And all the devices are still visible in the U’Zigbee2MQTT frontend and happily report every few minutes as if nothing had happened… The logs from Z2M, HA and Mosqitto show nothing worth mentioning. As if HA I set up an automation that automatically removes all devices from the one receiver after a few hours. I can’t explain it. Really every 1-2 days. It’s enough if I change the names of each device in the Z2M frontend and activate “update HA”. Then they’re back in the HA as if nothing had happened. That’s frustrating me. I really hope you can help me. :confused:

My setup:
Everything runs on a Pi 5 Linus separately in Docker-Compose: Home Assistant, Zigbee2MQTT, Zigbee2MQTT_2 (the one on the repeater), Mosquitto, AdGuard, nginx, esphome
one Mosquitto for zwo Z2M´s

I’ve already set WiFi channels far away from the ZigBee channels. But as I wrote, it can’t be the reception. All devices register with Z2M. Sry for my English :grimacing:

You don’t need two coordinators for this. You just need more zigbee devices that act as s repeaters so that your mesh extends to cover he area.

Hi, yes that is theoretically correct. If you have enough options and power connections in the spaces in between. :sweat_smile:

Because you have this unconventional set-up, I have no idea how to repair that. You certainly could, however easily run a ZHA network and a Z2M network and all would be happy. I do this myself. 2 Z2M coordinators may be causing unintended results,

Thanks for your comment. And yes, that’s true, it’s so simple that I’m surprised I hadn’t thought of it before. I think it would be a bit of a shame to switch everything to Zigbee, as I would then have to forego many of the options for the sensors. But switching just one area would really be fine.

But I wrote in detail about the problem with ChatGPT 2 days ago. Since you can’t set up two brokers for MQTT in HA, we created a standard broker and a second one that only acts as a bridge and passes on the information about the sensors in the background. So far it’s working quite well. If after a week no sensors have disappeared and everything continues to run smoothly, I can share the compose and configuration yamls here. Best regards

1 Like

The problem is solved. I haven’t had any devices that have gone offline for several weeks now. The solution was to provide two mosquitto brokers in addition to the two Zigbee2MQTT containers. “depends_on” and " environment" refers directly to the respective broker and one acts as the network_mode: bridge.

Here is the code for Docker-compose:

services:
  homeassistant:
    container_name: homeassistant
    image: 'ghcr.io/home-assistant/home-assistant:stable'
    depends_on:
      - mqtt
      - mqtt_2
      - zigbee2mqtt
      - zigbee2mqtt_2
    volumes:
      - ./homeassistant/config/:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    network_mode: host

mqtt:
    container_name: mqtt
    image: eclipse-mosquitto:latest
    ports:
      - 1883:1883
      - 9001:9001
    restart: unless-stopped
    volumes:
      - ./mosquitto/:/mosquitto
    command: 'mosquitto -c /mosquitto-no-auth.conf'
    networks:
      dockernetwork:
  mqtt_2:
    container_name: mqtt_2
    image: eclipse-mosquitto:latest
    ports:
      - 1884:1884
      - 9002:9002
    restart: unless-stopped
    volumes:
      - ./mosquitto_2/:/mosquitto
    command: >
      mosquitto -c /mosquitto-no-auth.conf
      --connection bridge_to_mqtt
      --address mqtt:1883
      --topic '#' both 0
      --try_private false
    networks:
      dockernetwork:
  zigbee2mqtt:
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt
    depends_on:
      - mqtt
    ports:
      - 8081:8081
    restart: unless-stopped
    volumes:
      - ./zigbee2mqtt/:/app/data
      - /run/udev:/run/udev:ro
    environment:
      - TZ=Europe/Berlin
      - MQTT_SERVER=mqtt://mqtt:1883  # Verknüpft mit dem ersten Broker
    networks:
      dockernetwork:
  zigbee2mqtt_2:
    container_name: zigbee2mqtt_2
    image: koenkk/zigbee2mqtt
    depends_on:
      - mqtt_2
    ports:
      - 8082:8082
    restart: unless-stopped
    volumes:
      - ./zigbee2mqtt_2/:/app/data
      - /run/udev:/run/udev:ro
    environment:
      - TZ=Europe/Berlin
      - MQTT_SERVER=mqtt://mqtt_2:1884  # Verknüpft mit dem zweiten Bro>#    network_mode: bridge
    networks:
      dockernetwork:

networks:
  dockernetwork:
    ipam:
      driver: default
      config:
        - subnet: 'xxx

Here is the code for the first Z2M-Configuration.yaml:

permit_join: true
mqtt:
  server: mqtt://deine IP:1883
  user: gehtdich
  password: nüschtan
serial:
  port: tcp://deine IP:6638
  baudrate: 115200
  adapter: ezsp
frontend:
  port: 8081
advanced:
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
  log_level: info
  last_seen: ISO_8601_local
  channel: 15
availability: true
homeassistant: true
device_options:
  legacy: false
devices:

blocklist:

Here is the code for the second Z2M-Configuration.yaml:

permit_join: true
mqtt:
  base_topic: zigbee2mqtt_2
  server: mqtt://deine IP:1883
  user: gehtdich
  password: nüschtan
  retain: true
  keepalive: 60
serial:
  port: tcp://deine IP:6638
  baudrate: 115200
  adapter: ezsp
frontend:
  port: 8082
advanced:
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
  log_level: info
  last_seen: ISO_8601_local
  channel: 15
availability:
  active:
    timeout: 20
  passive:
    timeout: 1500
homeassistant: true
device_options:
  legacy: false
  homeassistant:
    last_seen:
      enabled_by_default: true
devices:

blocklist: