MQTT Discovery with UI-Based Setup

With the move to UI based setup, I was hoping that I could integrate with my MQTT server easily. It connects just fine, but discovery doesn’t work and there are no configuration options for discovery.

It appears that there is some sort of prefix you’re supposed to use or something, but all of my stuff is under <username>\device\topic so I don’t know how that’s supposed to work. To me it should query for all of them everywhere, and let us pick which to add.

In the mean time, is there some guide on how to make Mosquitto present the topics in a way that HA will recognize? I can’t find anything in the docs.

It really does not matter how your topic are structured. However, HA does not scan your mqtt messages to auto-detect devices/entities. For auto-discovery to work, your device needs to send a auto-discovery message to HA.

an example of such message :

topic : homeassistant/sensor/xiron_2202/humidity/config
message : '{"unit_of_measurement":"%","device_class":"humidity","value_template":"{{ value_json.HUM }}","state_topic":"rflink/Xiron-2202","name":"garage_humidity","unique_id":"Xiron_2202_humidity","device":{"identifiers":["xiron_2202"],"name":"xiron_2202","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'

So how does one get owntracks to send this?

I don’t use owntracts, but I guess the integration sets everything up.

If you use the integration it uses http, which is fine as far as it goes, but I wanted to use MQTT because it appears to have much better battery life.

If Owntracks does not publish discovery topics then you will have to manually define your entities in YAML.

So I think it works if you install the owntracks integration, ignore the HTTP instructions, and then the MQTT stuff will just work afterwards.