MQTT Client - LWT issues

Hi

I am probably completely getting the call wrong but trying to understand how the MQQT Client App is using LWT

Am I reading this right - but it appears to be declaring that the Homey MQTT Client is offline ?

Because it is online and working fine.

Anyone any ideas ?

Ideally I am looking for NodeRed/Hubs/Homey to reflect the status of this connection

If the message is retained (which it is), and you don’t clear or overwrite it, the LWT topic will show the LWT value indefinitely. So you need to reset it when the MQTT Client app connects again.

Thanks

I believe I am misunderstanding LWT function.

I had thought that LWT was sent by client to MQTT Broker on first connection and that the MQTT Broker executed LWT upon the event of the client disconnect.

I’ll go and read up on it, because it looks like the MQTT client writes LWT to the MQTT Broker declaring it is offline when it first connects and so it reports it is offline when connected.

I’ll figure it out :slight_smile:

That’s exactly what it does. But also literally just that. It will not clear the message, or magically replace it by “online”, when the connection is established again.

No, what’s happening is this:

  • the client connects, stating its LWT message
  • the client disconnects, so the broker posts the LWT message which is retained
  • the client connects again without clearing or updating the retained LWT message

So the last message posted to the LWT topic is “offline”, and it will remain there until you clear it.

Thanks

So I create a flow in Homey to set NodeRed/Hubs/Homey to subscribe and if it ever does not equal online, change it to online?

Then if Homey MQTT Client goes offline it will be changed to offline by the MQTT Broker.

On it

Many thanks for that

1 Like

PERFECT

Works a treat !!

Thanks