[MQTT-Core] Support for RETAIN



  • RETAIN is an essential feature of any MQTT implementation. Without RETAIN, device information can get lost when a service like Home Assistant who uses MQTT subscription to get device info, has an issue. For instance, when Core sends out an MQTT discovery message (essential for Home Assistant auto-discovery) the RETAIN flag ensures that the device is still available after Home Assistant reboots.



  • Hi: Is there an update to this request? It seems to me that this would be very easy fix ... just adding the 'retain flag' parameter to mqtt messages. This is a very essential feature for mqtt auto-discovery with remote clients (such as Home Assistant). Without retain, Home Assistant loses all the configuration details about the M5Stack device after every HA reboot. The M5stack becomes 'unavailable' to HA and it's only after rebooting M5Stack that the device becomes available again.



  • What all have you tried and are you using uiFlow or Arduino?

    I'm pretty sure they implemented it a while back, as I originally requested it more than a year ago. I haven't tested it recently, but I believe it was working before. Let me do some digging and I'll see what I can come up with.





  • I need it too, in UIFlow.



  • The MQTT Adafruit forum told me: "An automatic process in order to synchronize the subscriber without any data loss?
    You can - please see this documentation about retained values here:
    [https://io.adafruit.com/api/docs/mqtt.html#retained-values](link url) “

    Checking the Github I've found an open issue about support of the MQTT retain Flag in M5 UIFlow code. See: [https://github.com/m5stack/UIFlow-Code/issues/1](link url)

    My PAHO subscriber client currently displays a zero value in the retain flag returned from the M5 publisher and Adafruit broker. Do you know the status of this issue?