Zigbee2mqtt devices alternating between unavailable and correct state

I have a zigbee2mqtt server running and the proxy addon in HA.
The status of all my zigbee devices alternates between unavailable and the respective entity status. It can be observed that the status changes to unavailable after a while (usually between 1 - 3 hours). After less than a minute (usually only 5 seconds), the correct status is then displayed again.

I run all the components on Proxmox:
HA: HASS-OS in VM
mqtt: lxc
zigbee2mqtt: lxc
zigbeecoordinator: lan-coordinator

Basically, every Zigbee device reports its status correctly. However, I am not sure why the status of the entities is always set to unavailable after some time.
Unfortunately, I have not been able to find any other similar cases in the forum.

Here is an example of a window sensor:

Is Zigbee2MQTT the only MQTT-based integration you use ?

No, there are several other components which are communicating through the same MQTT base topic in HA as well.
For example Milight.

And these don’t show that behaviour ?

Good advice, I hadn’t checked that yet.

These devices do not actually exhibit this behaviour. So far I have only noticed this with devices that are connected via z2m.

Do you have availability turned on in z2m? I saw similar behavior when I had it enabled. When I disabled it, everything corrected itself.

It seems to be switched off:

You probably just needed to increase the time-out for battery devices that sleep (under the advanced availability settings).

Having this enabled is a good idea as you can set up notifications for devices that fall off the network.

Though this is not helping Patrick.

@blade-of-fire those unavailable times don’t correspond to times you restarted home assistant do they?

Or times you enabled hidden entities in the mqtt integration (reloads the whole integration after 30 seconds resulting in unknown states briefly).

1 Like

True. Add that to my (ever growing) list of things to do. :smiley:

Oooohhhh that would be nice… However, I can’t remember the last time I had a device drop off my mesh to be honest (finding the biggest wooden thing I can find to knock on lol). But having the notifications wouldn’t hurt either.

I got alerted that my lane gate monitor was unavailable the other day. Its an Aqara contact sensor PCB in a waterproof box. Turns out the battery had fallen out :rofl:

2 Likes

lmao! I actually just replaced all my SmartThings MP sensors with Aqara ones for kind of the same reason. The battery holder in a few of my MP sensors wore out and the batteries would lose contact sometimes. But, they would only go offline for an hour or two and then reconnect.

I noticed that yesterday :slight_smile:

The “unavailable” messages also appear when nobody is at home and there is no other activity in the HA.

What I have just noticed is that the “unavailable” messages appear on all devices at exactly the same time.
The message may not even be coming from the communication from the device to z2m, but rather from the mqtt communication.
Strangely enough, I don’t have any of these messages on other devices.

What other devices?

Are they being supplied by zigbee2mqtt as well?

Or another integration?

Sorry, that was unclear.

I meant other devices which are communicating over mqtt.

But are they being supplied by zigbee2mqtt?

If not, then this appears to be a problem with zigbee2mqtt.

Check its logs.

Sorry for the late answer.
I’m still not sure what the problem was, but I’ve managed to solve it in the meantime.
I suspect that the LAN coordinator I was using was the problem. I still had a Sonoff Zigbee stick and have now set up the whole Zigbee network again. Since then, the entities have been working as desired and I no longer have any “not available” messages.

Thanks anyway for your active help.

I think I rejoiced too soon.
In the newly set up Zigbee network with the Sonoff zigbee usb stick, I first connected all devices supplied with continuous current (except for the Ikea Tradfri lamps), then the battery-operated devices.
I did not initially connect the Ikea lamps to the network (due to time constraints). I only did that yesterday.
Since the Ikea lights have also been connected to the Zigbee network, I’ve been having the same problems with all the devices going to “unavailable” from time to time, but then reappearing after a short time.
I’m really at a loss now.

Other devices, which are communcating over mqtt are not supplied by zigbee2mqtt.

Did you check the Z2M logs? I’d be willing to bet that you have errors there.