Z2M devices stay unavailable after HA restart - Z2M restart required

Hello,

For some time now, when I restart Home Assistant, I have to restart Zigbee2MQTT (installed on another server) for the devices to work again in Home Assistant.

When I restart Home Assistant, I can leave it for a long time without doing anything, and the devices will still be “unavailable” even though they are functional and usable in the Zigbee2MQTT UI.
This only seems to affect Zigbee2MQTT devices and not the other MQTT devices I have.

Does anyone have any idea where this is coming from?
I haven’t seen anything in the Zigbee2MQTT logs or in Home Assistant either:

2025-10-30 08:45:01.786 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2025-10-30 08:45:01.786 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 0.00 seconds

2025-10-30 08:45:02.076 INFO (MainThread) [homeassistant.components.number] Setting up mqtt.number
2025-10-30 08:45:02.079 INFO (MainThread) [homeassistant.components.light] Setting up mqtt.light
2025-10-30 08:45:02.080 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up mqtt.binary_sensor
2025-10-30 08:45:02.080 INFO (MainThread) [homeassistant.components.sensor] Setting up mqtt.sensor
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.button] Setting up mqtt.button
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.select] Setting up mqtt.select
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.text] Setting up mqtt.text
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.update] Setting up mqtt.update
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.lock] Setting up mqtt.lock
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.event] Setting up mqtt.event
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.image] Setting up mqtt.image
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.climate] Setting up mqtt.climate
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up mqtt.alarm_control_panel
2025-10-30 08:45:02.081 INFO (MainThread) [homeassistant.components.switch] Setting up mqtt.switch
2025-10-30 08:45:02.083 INFO (MainThread) [homeassistant.components.sensor] Setting up mqtt_room.sensor
2025-10-30 08:46:23.300 INFO (MainThread) [homeassistant.components.mqtt.client] 
MQTT client initialized, birth message sent

Do you have a Mosquitto Broker installed on the separate sever?

Please share your Z2M and broker config.

I’ve also been having this problem for quite some time now.

But in my case, it only seems to happen when I do some updates to the HA Core, but I still have to investigate the OS updates.

I’m using Proxmox, HA OS in a VM, Z2M and EMQX in separate LXCs.
Nothing in the logs indicates any problem.

Are these the same ?

Yes, I had forgotten about it. It is installed on the same server as Z2M.
Here are the configurations.

Mosquitto:

listener 1883
protocol mqtt
password_file /mosquitto/config/passwd

Z2M:

version: 4
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://10.0.1.9:1883
  user: #####
  password: #####
  include_device_information: true
  keepalive: 60
  reject_unauthorized: true
  version: 4
serial:
  port: >-
    /dev/serial/by-id/usb-SMLIGHT_SMLIGHT_SLZB-MR1_4e07589a696cef11be6a99adc169b110-if00-port0
  baudrate: 115200
  adapter: ember
  rtscts: false
advanced:
  log_level: info
  channel: 20
  network_key:
    - ...
  pan_id: 42576
  ext_pan_id:
    - ...
frontend:
  enabled: true
  port: 8080
homeassistant:
  enabled: true
  experimental_event_entities: true
  discovery_topic: homeassistant
onboarding: false
devices:
    - ...

Only during an update? Not during a manual restart?

Yes, it seems:


This was happening to me so I created an automation that runs when HA starts and it calls:

triggers:
  - trigger: homeassistant
    event: start
actions:
  - delay: "00:00:30"
  - action: hassio.addon_restart
    data:
      addon: 45df7312_zigbee2mqtt

This solves the problem.

I won’t say that is cause, but you don’t have a persistence file configured in your mosquitto configuration.

without persistence file, HA does not receive the retained discovery messages.

Apparently so.
If you look at the screenshot I sent, I updated around 11:20 and the z2m was disconnected for a while until I manually restarted it.
Around 23:00 I manually restarted HA and the z2m remained connected.

Could you post your Z2M configuration?

You have your MR1 connected via USB?

I think you need this more:

persistence true
persistence_location /var/lib/mosquitto/


include_dir /etc/mosquitto/conf.d
password_file /etc/mosquitto/passwd
listener 1883


Unfortunately, I’m using EMQX, not Mosquitto.

I updated my configuration with persistence, I’ll see if that changes anything!

Yes, absolutely! Could that cause a problem?
I should point out that Home Assistant is running in a VM, so when it restarts, it doesn’t restart the USB ports.

Yes that definitely could be the source of your problem. You can test the theory by changing the MR1 to Ethernet mode although that will need some tweaks to your Z2M config.