retained message
A message the broker keeps and hands to anyone who subscribes later, so they get the last known value at once.
A publish with the retain flag set replaces the broker's stored message for that topic; every new matching subscription immediately receives it with retain=1, and a retained publish with an empty payload deletes it.
Examples
The sensor publishes the fan state
onretained togh1/dev-a1/state/fanat 8:20; a dashboard subscribing at 9:00 getsonat once.Clearing a retained value needs a null payload,
mosquitto_pub -t gh1/dev-a1/status -r -n, not the text"".