No the addon supports this. Here’s a mosquitto specific guide on this. As you can see the only requirement for the broker to support persistent sessions is to have persistence true
in the config. Everyone running the mosquitto addon has this, it’s right here in the config:
However Home Assistant’s MQTT integration does not support this. The library it uses to talk to the broker is paho-mqtt and here’s how it sets up the client:
https://github.com/home-assistant/core/blob/ebc883b43ff9ca00d3426bbd0bdfdab707576252/homeassistant/components/mqtt/__init__.py#L861
If you look in the Paho MQTT docs at the page I linked it shows that its constructor has these options:
Client(client_id="", clean_session=True, userdata=None, protocol=MQTTv311, transport="tcp")
To use a persistent session clean_session
must be false. But HA does not specify it therefore it is always going to default to True
.
@phanosp you’ll have to make a feature request for this. That being said, you’ll also have to explain what you would expect this to do. The sensor’s state should always be the latest value so what are you expecting HA to do with the stale messages? They wouldn’t be used to set the state of the sensor as that would be incorrect by the time they’re received.