Here is another great explanation on how to remove those retained messages
It’s an included feature now… by far the easiest way…
very interesting topic.
I have a problem with retained message. I have set retain in a lot of my device (sensor) but I would remove it now (I remove form config.yaml). When I see Mqtt message with Mqtt explorer I see retained is remove un device topic, but stay inzigbee2matt/device/availability. If I remove it manually (in Mqttexplorer or in HA with publish a blank retain message a the same topic. It works, but after few time the retain message come back. Have you a clue. I will remove that because when a sensor is out of network a long time ago I see it in HA Unavailable now it show always the last temperature and its not easy to know he is out of network
Because whatever is publishing the payload is publishing it as a retained message. Every time it publishes a new value, that value is retained by the MQTT broker.
The correct way to report an MQTT Sensor’s availability is not by how its payload is published (retained/not retained) but via its availability_topic.
I don’t understand your answer. I’m not searching to create a Mqtt device. They are automatically generate with zigbee2mqtt (auto discovery in HA). But the sensor who is out from Zigbeenetwork don’t send new value. I see it in MqttExplorer. But his under topic “availability” is retained flag online. Is this the auto discovery device who does that ?
It’s clear to me that you didn’t understand it because I didn’t explain how to “create a MQTT device”. I explained why the retained message returns because whatever publishes it is responsible for it and in your case that would be Zigbee2MQTT.
Anyway, if that is still unclear then hopefully someone else can help you. Good luck.