I need help getting mqtt discovery working

Hi,

I’ve now read manuals and different problem posts here several times, but can’t get the discovery to work. I have some devices I try to configure from node red. But to simplify, I send this message (observed from mosquitto_sub):

homeassistant/sensor/ulko/config {"name":"ulko","state_topic":"sensor/ulko","unit_of_measurement":"°C","value_template":"{{ value_json.temperature }}","device_class":"temperature"}
homeassistant/sensor/ulko/config {"name":"ulko","state_topic":"sensor/ulko","unit_of_measurement":"%","value_template":"{{ value_json.humidity }}","device_class":"humidity"}
homeassistant/sensor/ulko/config {"name":"ulko","state_topic":"sensor/ulko","unit_of_measurement":"V","value_template":"{{ value_json.voltage }}","device_class":"voltage"}

That device is a bt beacon broadcasting data over bluetooth, which I have grabbed from another raspi, and sent out using node-red. But that’s irrelevant, it is all about the message format. What is wrong, why won’t the device appear?

The following is also grabbed from the mqtt bus:

sensor/ulko {"rssi":-79,"type":"ruuvi","humidity":67.7175,"temperature":19.029999,"pressure":99632,"accelerationX":0.084,"accelerationY":0,"accelerationZ":1.048,"voltage":2149,"txpower":4,"movementCount":33,"sequence":51051,"address":"c3:47:44:54:1d:4f"}

So the topic is different, like set in the config message. I’m now blind to my mistakes, what could I do wrong?

Other info: HA is up to date as of today, running on raspi3. MQTT integration has the discovery set on. The device is even rebooted in the meanwhile while upgraded to latest. Some other devices using MQTT integration (plejd) seem to work. Mqtt QoS is 0 and retain false. No obvious errors in logs.

Hi,
You should use different config topics for each sensor and also different names. Try as follows:

homeassistant/sensor/ulkoT/config {"name":"ulkoTemp","state_topic":"sensor/ulko","unit_of_measurement":"°C","value_template":"{{ value_json.temperature }}","device_class":"temperature"}
homeassistant/sensor/ulkoH/config {"name":"ulkoHum","state_topic":"sensor/ulko","unit_of_measurement":"%","value_template":"{{ value_json.humidity }}","device_class":"humidity"}
homeassistant/sensor/ulkoV/config {"name":"ulkoVolt","state_topic":"sensor/ulko","unit_of_measurement":"V","value_template":"{{ value_json.voltage }}","device_class":"voltage"}

And set retain to true, if you want the config to persist after Home Assistant restarts

3 Likes

Thanks @federico this solved it. Pheew, it took many hours of trying :grinning:

1 Like