[SOLVED] Check if an Mqtt Item is Offline

Hello Guys,

my problem is, that my mqtt items are always online in paper ui. Sometimes the xiaomi/aqara items are not connected to my zigbee2mqtt bridge. If this happend, I just notice that if something does not work.

Is there any solution to check if a mqtt Sensor haven’t send a message for x secondes, so i know its offline?

Best Regard
Fabian

Using the search function I found several related topics that may help. Search results for 'check if mqtt item is offline' - openHAB Community

If the issue is with zigbee2mqtt you may want to check github for a solution. GitHub - Koenkk/zigbee2mqtt: Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨

You need to find out how often the item should be reporting back and use that as a kind of watchdog
See: Design Patterns: Generic Is Alive

1 Like

The proper MQTT way to do this would be to have the device use a LWT. But in this case I don’t think that’s possible as the LWT is for the zigbee2mqtt server itself.

Next best would be to have zigbee2mqtt report on some topic where a device is online or not. Look carefully at the zigbee2mqtt docs to verify this is not happening. If it indeed in not happening, I’d open a feature request issue. That server is in the best position to know if a device is online or not.

Failing getting the online status reported at the source, the DP Vincent linked to is your best bet.

Expire Binding is the solution for my problem. Dont know that such a binding exist. thank you.

There is another solution with zigbee2mqtt

Add the folowing lines to the configuration.yaml file

advanced:
  availability_timeout: 120

AFTER the ports section and BEFORE the devices section

Zigbee2mqtt will check if your devices are online every 120 seconds and publish an MQTT message
You can then pick that up in openHAB

1 Like

The problem with the expire binding solution is that some zigbee end nodes will only report every few hours and it could be a full day before you detect that the device is offline