[MQTT] Availability Topic not working?

So I’m completely new to MQTT. I started using it now to integrate a few Shellys. So I set up Mosquitto using the openhabian installer and then the MQTT binding (openHAB 2.5.5).

In the binding, I set up the bridge and one “Generic MQTT Thing”.

If I understand it correctly, there is the possibility to set an “availability topic” for this thing (at least its parameters suggest this). So when this topic changes, the status of the thing in openHAB is updated correspondingly. E.g. thing disconnects and openHAB sees it and displays the thing as OFFLINE.

But no matter what I put into those configuration options, it does not work. The Thing is always shown as ONLINE. The MQTT tree looks correct to me, /shellies/shelly…/online changes to false when I disconnect it.

MQTT tree for the Shelly:
image

Configuration of the Thing:

And the Thing when it’s offline:
image

Am I understanding this correctly? Why does openHAB not display the Thing as OFFLINE?

Before going too far along, I must mention that there is a Shelly binding that does not require MQTT which should be far simpler to set up and use.

I don’t know whether or not that availability topic is supposed to control the ONLINE/OFFLINE status of the Thing. It could be used to update the Items linked to that Thing’s Channels to UNDEF when it goes offline only. Typically, that ONLINE status for the Thing is mostly just an indicator that the communications path is still up; in this case that OH is still connected to the broker.

Whether or not the Shelly is online or not, you can still send messages to it and, if the messages are retained, the Shelly will act upon them when it does come back online. So the communications path is still online even if the device is not.

That would indeed be a simpler approach and I did not see that there was a binding specifically for the Shellys. So thank you for that hint. But since I stumbled upon MQTT related things quite often recently I thougt this would be a good reason to more deeply understand how MQTT works. And after some reading, I think I got most of it. So now it’s time for practice :slight_smile:

That would be possible, but the Items linked to this Thing’s Channels do exactly nothing, e.g do not change to UNDEF either.

I just found an older post referring to this Github issue saying it was actually broken for HomeAssistant Things (I’m using Generic MQTT Thing instead), but this could quite probably be related. Also that post and issue seems to confirm my understanding of the intention this setting has - Device offline (e.g. battery empty) -> Thing OFFLINE in openHAB, even though the connection is still available through the MQTT broker and a potentially retained message.