Skip to content

Zigbee2MQTT Devices Keep Dropping Offline — A Four-Layer Decision Tree to Get Them Stable

You pair a device, it works for a few months, then it starts dropping — online by morning, gone by evening, fixed by a coordinator restart, broken again the next day. This kind of repeated offline is more frustrating than a pairing failure, because there is no fixed error message and the behavior changes each time. It wastes hours of rebooting.

I have run four Zigbee networks (30 / 45 / 62 / 87 devices), and every repeated-dropout root cause I found landed in one of four layers: the device layer (the device itself dropped), the link layer (the signal or route cannot reach it), the coordinator layer (the bridge/hub stalled), and the MQTT layer (bridge state never reached HA). Identify the layer first, then act — do not start with a restart.

This article does not repeat the pairing flow (if it cannot join, read Zigbee2MQTT Pairing Failures), nor gateway selection or mesh tuning (those are covered by Zigbee2MQTT Gateway Config and Zigbee Mesh Optimization). It only covers devices that are already in the network but keep going offline. All config snippets come from my own running networks; copy them as-is.

1. Separate Two Illusions First: Actually Dropped vs Stale State

Before touching anything, split "the device is really offline" from "HA state is not refreshing." They need completely different fixes.

Actually dropped: the device stops publishing. zigbee2mqtt.log shows Device '0x...' disconnected, and no new state messages arrive for a long time.

Stale state: the device is online and still publishing, but the HA entity shows "unknown" or holds an old value. The cause is that Zigbee2MQTT disables advanced.last_seen by default, so HA MQTT entities only update when an explicit message arrives; when a device sleeps (battery sensors) or the broker drops a message, HA does not refresh.

How to tell them apart (commands vary slightly by Z2M version and deployment — check against your site):

# 1. Is this device still publishing?
mosquitto_sub -h localhost -t 'zigbee2mqtt/<device>/state' -v

# 2. Is the bridge itself online?
mosquitto_sub -h localhost -t 'zigbee2mqtt/bridge/state' -C 1

# 3. What is this device's link quality?
mosquitto_sub -h localhost -t 'zigbee2mqtt/<device>/linkquality' -C 1

If step 1 still produces fresh messages and step 2 reads online, the device has not dropped — it is an HA display problem, so enable last_seen. If step 1 is silent for a while and step 2 flips between offline and online, it is a real drop, so go to the tree in section 2.

Key config (Zigbee2MQTT documentation; the advanced and top-level availability blocks — field placement varies slightly by Z2M version, so check your installed version's docs):

advanced:
  last_seen: ISO_8601      # default is disable; without it HA never reflects real offline
  cache_state: true        # default true; restore last state after reconnect, avoiding all-unknown

# top-level availability (Z2M 2.x offline detection)
availability:
  enabled: true
  active:
    timeout: 10            # in MINUTES; mains devices offline after 10 min silent
  passive:
    timeout: 1500         # in MINUTES; battery devices offline after 25 h silent

Note: availability is a top-level key, and active.timeout / passive.timeout are in minutes (default 10 for active, 1500 for passive), not seconds. Older Z2M versions used advanced.availability_timeout (seconds); 2.x moved it to a top-level nested block. Confirm against your version's docs before changing anything. Without this block, HA Zigbee entities are mostly "fake online" — a device can be down for two hours and still show ON. That was the most painful one I hit.

2. The Four-Layer Decision Tree

device repeatedly offline
├─ only 1 device
│  ├─ linkquality low (<80)         → link layer: move it / add router / change channel
│  ├─ LQI ok but hops >= 4          → link layer: long route, add a repeater
│  ├─ battery device, parent flaky  → link layer: fix the parent router first
│  ├─ device power/battery dead     → device layer: swap battery / check power
│  └─ all of the above normal       → device layer: reset & re-pair / check definition
└─ many devices at once
   ├─ bridge/state flapping         → coordinator layer: serial / power / restart
   ├─ coordinator CPU near 100%     → coordinator layer: concurrent OTA / too many devices
   ├─ channel RSSI jumped           → link layer: WiFi same-channel, change channel
   └─ HA entities all unknown       → MQTT layer: broker disconnect / queue full

2.1 Device layer — a single device drops, rule out the device itself

Symptom: one device drops, the rest are fine.

# Pull metadata: type, battery, parent, lastSeen
curl -s http://localhost:8081/api/v1/devices/<device> | jq '{type, battery, lastSeen}'
# Or read its association history from the log
journalctl -u zigbee2mqtt -n 200 | grep -i "<ieee>"

Common causes: - Battery nearly dead: a low battery lengthens the wake cycle and raises forward-failure rate, which reads as "works, then fails." Swap the battery and watch for 24 hours. - Unstable power: a plug or bulb on a flaky strip, or a coordinator whose USB supply is insufficient and resets downstream routers. - Wrong definition: the device was identified as the wrong type, so some commands never send and it behaves oddly.

In repeated dropouts, the link layer is the most frequent root cause. When a device "really drops" while the coordinator is online, it is usually that the signal cannot reach it.

LQI reading (link quality in zigbee-herdsman, 0-255): 180+ is strong, 120-180 usable, 80-120 flaky, <80 dangerous. A device that keeps dropping sits below 80.

Channel: Zigbee 2.4 GHz shares its band with 2.4 GHz WiFi. The Zigbee2MQTT docs allow four channels — 11/15/20/25. The default or early-picked channel 11 collides hardest with WiFi channel 1. The moment a neighbor swaps their router, your devices start flapping. This kind of "repeated" has a strong time pattern (drops when neighbors' WiFi is busy, fine when it is quiet) — that pattern is nearly a lock on channel.

Fix: move Zigbee to a clean channel (15/20/25 for home), set network_parameters.channel, restart Z2M, and observe for 24 hours. For channel scanning and router placement, see Zigbee Mesh Optimization.

2.3 Coordinator layer — many devices drop together, watch the bridge and hub

Symptom: a batch of devices goes offline at once, and zigbee2mqtt/bridge/state keeps flipping between online and offline.

The bridge itself (coordinator + the Z2M process) is failing, not a single device.

# Bridge state
mosquitto_sub -h localhost -t 'zigbee2mqtt/bridge/state' -C 1
# Coordinator info (firmware / chip / channel)
mosquitto_sub -h localhost -t 'zigbee2mqtt/bridge/info' -C 1 | jq '{adapterRevision, channel, coordinatorType}'
# Was the serial port reset by the kernel (classic underpowering signature)
dmesg | tail -30 | grep -iE "tty|usb"
# Coordinator process load
top -p $(pgrep -f zigbee2mqtt)

Common causes: - Serial / power: insufficient USB current or an over-long cable makes the kernel reset the port periodically, and the whole network drops with it. dmesg shows the USB reset events. - Concurrent OTA storm: a batch of devices OTA at once saturates the coordinator CPU for minutes, and the network drops. Production must use ota.update_by_hand: true plus batching (see Zigbee2MQTT Gateway Config). - Device count past the coordinator's ceiling: an old CC2531 chip degrades badly near its limit; move to CC2652P / SLZB-06P.

2.4 MQTT layer — devices online but HA shows all unknown

Symptom: every device is online in the Zigbee2MQTT frontend, yet HA is full of unknown, or entities stop refreshing.

The segment from the bridge to Home Assistant broke. Zigbee itself is fine.

# 1. Is HA's MQTT integration pointed at the same broker?
#    Settings -> Devices & Services -> MQTT -> broker / port / connected?
# 2. Is the broker queue dropping messages (discovery/state lost)?
mosquitto_sub -h localhost -t '$SYS/broker/messages/queue/drop' -v
# 3. Is HA still receiving discovery traffic?
mosquitto_sub -h localhost -t 'homeassistant/#' -v | head -20

Common causes: - Broker restart / disconnect: a tens-of-seconds Mosquitto restart pushes HA entities back to unknown. Enable cache_state: true so it replays the last state after recovery (Mosquitto documentation). - Queue full: max_queue_size too small, so discovery messages are silently dropped and HA never sees them. Raise the queue and check for a stalled HA client. - base_topic mismatch: HA's MQTT discovery prefix does not match Z2M's base_topic, so entities never build.

3. Three Production-Style Post-Mortems

The following are based on typical production scenarios; specific IPs, ports, and device counts are site-specific.

Scenario 1 (based on a typical production scenario): neighbor's new router, all sensors drop every 10 minutes

Symptom: in an 87-device network, the living-room and bedroom battery sensors went offline every 10-15 minutes, worse in the daytime than at night.

Root cause: the neighbor's new WiFi 6 router defaulted to channel 1, and my Z2M sat on channel 11. The two bandwidths overlap heavily. Daytime neighbor WiFi usage pushed my LQI from 160 down to 60, and the devices flapped.

Investigation: linkquality showed many devices under 80, so I suspected the channel, scanned RSSI, and found 11/12/13 smothered by WiFi Ch1. I moved to channel 25.

Fix:

network_parameters:
  channel: 25

Within two minutes LQI recovered above 180, and it held for 24 hours. The time pattern is the tell: if the drops line up with neighbors' WiFi-heavy hours, it is the channel.

Scenario 2 (based on a typical production scenario): coordinator on the TV stand, collective drops at 3 a.m.

Symptom: 60+ devices dropped together between 2 and 3 a.m., fixed by restarting the coordinator, then recurring every few days.

Root cause: the coordinator's USB was plugged into the TV cabinet, right next to the WiFi router, on a cable with no heat dissipation. Overnight router/AC power shifts plus near-field interference overheated the chip and caused periodic USB resets. dmesg had the USB reset events.

Fix: move the coordinator 1.5 m from the router, up and clear, add cooling, and use a short, stable USB cable. The same coordinator ran six months clean after the move. When the whole network drops at once and a restart fixes it, check the coordinator's power, location, and serial first — do not touch the devices.

Scenario 3 (based on a typical production scenario): batch OTA leaves a wall of unknowns, MQTT queue blamed

Symptom: after manually triggering OTA on 12 devices, HA Zigbee entities turned en masse to unknown, while the Zigbee2MQTT frontend still showed the devices present.

Root cause: the concurrent OTA saturated the coordinator CPU for about five minutes. During that window the broker queue backed up and discovery/state messages were dropped, so HA clients received nothing. This is a coordinator-layer plus MQTT-layer overlay: the root is coordinator load, the symptom is in HA.

Fix: ota.update_by_hand: true for manual triggers, batches of three with five-minute gaps, a 30-minute offline-alert silence before upgrading, and cache_state: true. After the batch finished, HA entities recovered. See the OTA section of Zigbee2MQTT Gateway Config.

4. Cheat Sheet

# Single-device health
mosquitto_sub -t 'zigbee2mqtt/<device>/linkquality' -C 1        # LQI; repeated drops usually <80
mosquitto_sub -t 'zigbee2mqtt/<device>/state' -v                 # is it still publishing?
curl -s http://localhost:8081/api/v1/devices/<device> | jq .     # metadata (type/battery/lastSeen)

# Bridge and topology
mosquitto_sub -t 'zigbee2mqtt/bridge/state' -C 1                 # online / offline
mosquitto_sub -t 'zigbee2mqtt/bridge/info' -C 1 | jq .           # chip / channel / firmware
curl -s http://localhost:8081/api/v1/networkmap | jq '.networkmap[0].nodes | length'

# Coordinator side
dmesg | tail -30 | grep -iE "tty|usb"                              # USB reset / power
top -p $(pgrep -f zigbee2mqtt)                                     # CPU saturated by OTA?

# MQTT / HA side
mosquitto_sub -t '$SYS/broker/messages/queue/drop' -v             # queue dropping messages?
mosquitto_sub -t 'homeassistant/#' -v | head                       # is HA still receiving discovery?

One-line decisions: - One device keeps dropping -> LQI, then hops, then battery; link layer first - Many at once -> bridge state, then coordinator CPU, then channel; coordinator layer first - Devices online but HA all unknown -> MQTT layer; enable last_seen + cache_state, check the queue

5. FAQ

Q1: I enabled last_seen, but HA still shows a long-gone device as online. Why?

availability is off, or active.timeout is too large. A device is judged offline only after a silent gap longer than that value. Mains (active) devices default to 10 minutes and battery (passive) devices to 1500 minutes (25 hours) — and the unit is minutes, not seconds. False alarms are almost always an un-tiered timeout, not last_seen.

Q2: Can auto-reconnect just fix repeated dropouts, so I skip the root cause?

No. Devices already in the network reassociate automatically after a drop, but until the root cause (channel, power, link) is removed, it repeats forever. Reconnect fixes "get back online," not "why it dropped." Locate the layer, then act.

Q3: How do I tell if it is the coordinator or a single device?

Count how many drop at once. One or two flapping is a single-device / single-link problem. A batch or whole-room drop points at the coordinator, bridge, or MQTT. Frequent bridge/state offline is a direct pointer to the coordinator.

Q4: Should battery-sensor offline states alert? They false-positive a lot.

Yes, but tier the alerts. Battery end-devices sleep and send nothing by design, so last_seen-based offline has delay. Use per-type thresholds (mains ~60 s, battery 300 s+), otherwise you get an alert storm. The false positives are almost always an un-tiered threshold, not last_seen itself.