MQTT LWT messages never getting sent?

Has anyone managed to successfully receive an MQTT LWT (last will) message from WLED when MQTT is configured?

I see in the code that it is registering a message, however I never see it show up when I turn off the WLED device. This makes it hard to write automations that react to the device disconnecting and/or to do something when the device connects.

Hi!
With my go-to testing broker broker.hivemq.com , i successfully receive the offline LWT message in the wled/[devicetopic]/status topic in the latest WLED master (2007020). Are you getting the (also retained) online message on connect?

However, because the MQTT keepalive period is set to 60 seconds, it will take at least a minute before the LWT is published. If your use case needs to know about the WLED light being offline more quickly, you could try lowering the MQTT_KEEP_ALIVE_TIME in mqtt.cpp, for example to 15 seconds :slight_smile:

I am getting the online messages no problem. I think I wasn’t waiting long enough if the keep alive time is 60 seconds, will try again and wait longer :slight_smile:

Yup, I just wasn’t waiting long enough!

1 Like