Add retain flag to Home Assistant's "Publish a packet"

Currently (0.113.3), you cannot use MQTT > Configure > Publish a packet to publish a retained message.

Screenshot from 2020-08-07 08-33-20

Adding this ability would allow users to delete retained messages on the broker. They can do that by publishing an empty retained message to the desired topic (i.e. the standard way of deleting a retained message).

This would be handy when using MQTT Discovery and there’s a need to purge a discovery topic containing a retained message. Currently it can be achieved by using a separate MQTT client (like mosquitto_pub or MQTT Explorer) but it would convenient if it could be done within Home Assistant.

I added my vote, because it is easier for newbies. It can be done in Home Assistant.

image

1 Like

Excellent point. Home Assistant is indeed capable of publishing retained messages and that ability simply needs to be exposed in “Publish a packet”. Until that happens (if ever), your suggestion to call mqtt.publish is the easiest way to delete a retained message (i.e. no need to acquire and use an external MQTT client).

Until this Feature Request is implemented (if ever), here’s how to delete a retained message contained in a discovery topic. The end-result is that the discovery topic will be removed from the broker and Home Assistant will remove the associated entity it had created.