MQTT2 auto detecting is not working stable for me

Hello community,

I’m trying to switch from MQTT1 to MQTT2.4. Until now all MQTT stuff is part of the item definition.

Now I would like to switch to Homie Convention and detect the devices and generate things. I’ve constructed an example device topic/value set and have published it using mosquitto_pub.

This is the set copied from mosquitto_sub output:
homie/test2222/$name TEST2222
homie/test2222/$homie 3.0
homie/test2222/$state ready
homie/test2222/$nodes but-left-up,but-left-dn,but-right-up,but-right-dn,system,connection
homie/test2222/but-left-up/$name Taste links oben
homie/test2222/but-left-up/$type Button
homie/test2222/but-left-up/$properties event
homie/test2222/but-left-up/event/$name Button Event
homie/test2222/but-left-up/event/$datatype string
homie/test2222/but-left-dn/$name Taste links unten
homie/test2222/but-left-dn/$type Button
homie/test2222/but-left-dn/$properties event
homie/test2222/but-left-dn/event/$name Button Event
homie/test2222/but-left-dn/event/$datatype string
homie/test2222/but-right-up/$name Taste rechts oben
homie/test2222/but-right-up/$type Button
homie/test2222/but-right-up/$properties event
homie/test2222/but-right-up/event/$name Button Event
homie/test2222/but-right-up/event/$datatype string
homie/test2222/but-right-dn/$name Taste rechts unten
homie/test2222/but-right-dn/$type Button
homie/test2222/but-right-dn/$properties event
homie/test2222/but-right-dn/event/$name Button Event
homie/test2222/but-right-dn/event/$datatype string
homie/test2222/system/$name System
homie/test2222/system/$type Housekeeping
homie/test2222/system/$properties File,Build,MAC
homie/test2222/system/File/$name Filename Source
homie/test2222/system/File/$datatype string
homie/test2222/system/Build/$name Date and Time of Build
homie/test2222/system/Build/$datatype string
homie/test2222/system/MAC/$name MAC-address of WiFi interface
homie/test2222/system/MAC/$datatype string
homie/test2222/connection/$name Connection Properties
homie/test2222/connection/$type Housekeeping
homie/test2222/connection/$properties IP,AP-MAC,RSSI,Uptime
homie/test2222/connection/IP/$name IP address
homie/test2222/connection/IP/$datatype string
homie/test2222/connection/AP-MAC/$name MAC of Accesspoint
homie/test2222/connection/AP-MAC/$datatype string
homie/test2222/connection/RSSI/$name Signal strength
homie/test2222/connection/RSSI/$datatype integer
homie/test2222/connection/RSSI/$unit dBm
homie/test2222/connection/Uptime/$name Uptime
homie/test2222/connection/Uptime/$datatype integer
homie/test2222/connection/Uptime/$unit min

No $stats, no arrays are in use. $type - I’m not sure, what is it for and what are valid values for this attribute.

What’s wrong? And more important: How to debug what’s wrong?

Thanks for help!

Set the log level for the mqtt binding to DEBUG via the console.

Hi H102,

openhab> log:get org.openhab.binding.mqtt

Is that the right binding? Looks like, I have some log entries. But not very helpful.

And I’ve checked the MQTT-Log of the broker - and I think I’ve found a possible reason for the unstable detection:
The binding subscribes to homie/+/$homie. So it can only see the homie/test2222/$homie 3.0 message. $name has been sent before and was ignored - may be…

After receiving the homie/test2222/$homie message, a second subscription to homie/test2222/$name is made. And after sending this message, a new thing can be found in the inbox…

Now I get a new Thing, but it has some missing data after first transmission of all nodes. When I repeat the data, the thing is corrected/completed. Good to know for an own implementation of a Homie device.

I will come back after implementing a real homie device.

Thanks and regards,

You should use OH 2.5M1. There was an error in 2.4 that prevented the binding to subscribe to every topic correctly.
Apart from that, when using mosquitto then raise the configuration value for stored retained messages otherwise your broker will start to forget older messages at some point.

Also: Right now the timeout for waiting on homie messages is super low (200ms). If your broker is not on the same device, you might run into issues. The next MQTT binding release will handle Homie message receiving different.

See also all open issues we have at the moment:✓&q=is%3Aissue+is%3Aopen+Homie

it sounds to me that I’m a bit to early with the idea to change the format of my sensors.
It would be helpful to have a little guide regarding timing and sequence of the messages. I offer my help to test the guideslines and to add my experiences.