Skip to content

Home Assistant MQTT Topic and Discovery Generator

Honest note: a browser does not reach your MQTT broker. What this page produces is the discovery topic, the JSON payload and the publish command, which you run yourself. Whether it lands, and whether the entity shows up, is something only your broker and Home Assistant can tell you.

Fill in the parameters

Three rules that must be right

Topic shape. <discovery_prefix>/<component>/[<node_id>/]<object_id>/config, default prefix homeassistant. node_id only organises topics and Home Assistant does not parse it; object_id is the final segment. Both accept only [a-zA-Z0-9_-], so a space or a non-ASCII character means silence.

The tilde abbreviation. Put a field keyed with a single tilde holding the base topic, then write ~/state and ~/set; the leading tilde is replaced with that base topic. The tilde must be at the start or the end of the value. On devices exposing many entities this measurably shrinks every payload.

Publish with retain. A discovery message published with retain is stored on the broker and replayed when Home Assistant restarts. Without it, every restart leaves the entity missing until the device republishes. The sturdier pattern is to also subscribe to homeassistant/status and republish all discovery payloads when online arrives.

Verifying the result

# 1. Subscribe to every discovery topic in a second window and watch
mosquitto_sub -h <broker> -u <user> -P <pass> -t 'homeassistant/#' -v

# 2. In Home Assistant
#    Settings -> Devices & services -> MQTT -> Devices should list the new device

If the entity does not appear, check in this order: a mistyped topic (most often the prefix or the component), nothing arriving on the broker as the subscription shows, invalid JSON because the shell ate the quoting in -m, and a payload missing state_topic or name.